Moxa W321-LX [67/80] Ioctl fd wdioc_gettimeout timeout

Moxa W321-LX [67/80] Ioctl fd wdioc_gettimeout timeout
W321/341 Linux Programmer's Guide
6-4
This example might actually print "The timeout was set to 60 seconds" if the device has a granularity of
minutes for its timeout.
3. Query the current timeout using the GETTIMEOUT ioctl.
ioctl(fd, WDIOC_GETTIMEOUT, &timeout);
printf("The timeout was is %d seconds\n", timeout);
Example 1:
/*
* Watchdog Driver Test Program
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <linux/types.h>
#include <linux/watchdog.h>
int fd;
/*
* This function simply sends an IOCTL to the driver, which in turn ticks
* the PC Watchdog card to reset its internal timer so it doesn't trigger
* a computer reset.
*/
static void keep_alive(void)
{
int dummy;
ioctl(fd, WDIOC_KEEPALIVE, &dummy);
}
/*
* The main program. Run the program with "-d" to disable the card,
* or "-e" to enable the card.
*/
int main(int argc, char *argv[])
{
int flags, get_timeout = 0;
int set_timeout = 60;
fd = open("/dev/watchdog", O_WRONLY);
if (fd == -1) {
fprintf(stderr, "Watchdog device not enabled.\n");
fflush(stderr);
exit(-1);

Содержание

Похожие устройства

Скачать
Случайные обсуждения