2 * Watchdog Driver Test Program
11 #include <sys/ioctl.h>
12 #include <linux/types.h>
13 #include <linux/watchdog.h>
18 * This function simply sends an IOCTL to the driver, which in turn ticks
19 * the PC Watchdog card to reset its internal timer so it doesn't trigger
22 static void keep_alive(void)
26 ioctl(fd
, WDIOC_KEEPALIVE
, &dummy
);
30 * The main program. Run the program with "-d" to disable the card,
31 * or "-e" to enable the card.
34 static void term(int sig
)
37 fprintf(stderr
, "Stopping watchdog ticks...\n");
41 int main(int argc
, char *argv
[])
45 fd
= open("/dev/watchdog", O_WRONLY
);
48 fprintf(stderr
, "Watchdog device not enabled.\n");
54 if (!strncasecmp(argv
[1], "-d", 2)) {
55 flags
= WDIOS_DISABLECARD
;
56 ioctl(fd
, WDIOC_SETOPTIONS
, &flags
);
57 fprintf(stderr
, "Watchdog card disabled.\n");
60 } else if (!strncasecmp(argv
[1], "-e", 2)) {
61 flags
= WDIOS_ENABLECARD
;
62 ioctl(fd
, WDIOC_SETOPTIONS
, &flags
);
63 fprintf(stderr
, "Watchdog card enabled.\n");
67 fprintf(stderr
, "-d to disable, -e to enable.\n");
68 fprintf(stderr
, "run by itself to tick the card.\n");
73 fprintf(stderr
, "Watchdog Ticking Away!\n");