2 * Watchdog Driver Test Program
10 #include <sys/ioctl.h>
11 #include <linux/types.h>
12 #include <linux/watchdog.h>
17 * This function simply sends an IOCTL to the driver, which in turn ticks
18 * the PC Watchdog card to reset its internal timer so it doesn't trigger
21 static void keep_alive(void)
25 ioctl(fd
, WDIOC_KEEPALIVE
, &dummy
);
29 * The main program. Run the program with "-d" to disable the card,
30 * or "-e" to enable the card.
32 int main(int argc
, char *argv
[])
34 fd
= open("/dev/watchdog", O_WRONLY
);
37 fprintf(stderr
, "Watchdog device not enabled.\n");
43 if (!strncasecmp(argv
[1], "-d", 2)) {
44 ioctl(fd
, WDIOC_SETOPTIONS
, WDIOS_DISABLECARD
);
45 fprintf(stderr
, "Watchdog card disabled.\n");
48 } else if (!strncasecmp(argv
[1], "-e", 2)) {
49 ioctl(fd
, WDIOC_SETOPTIONS
, WDIOS_ENABLECARD
);
50 fprintf(stderr
, "Watchdog card enabled.\n");
54 fprintf(stderr
, "-d to disable, -e to enable.\n");
55 fprintf(stderr
, "run by itself to tick the card.\n");
60 fprintf(stderr
, "Watchdog Ticking Away!\n");