ADLINK CSA-5200 User Manual
Page 38

38
CSA-5200
* the Watchdog 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;
if(argc == 2 && !strncasecmp(argv[1], "-h", 2))
{
fprintf(stderr, "wdogfeed options:\n");
fprintf(stderr, "-e<1|0>:
Turn on/off the watchdog timer.\n");
fprintf(stderr, "-b<1|0>:
Enable/disable the bypass lan.\n");
fprintf(stderr, "-t:
Query the watchdog timeout parameter.\n");
fprintf(stderr,
"-s:
Change the watchdog timeout parameter.\n");
fprintf(stderr, "For example:\n");
fprintf(stderr, "./wdt-test -h
// Print the help menu\n");
fprintf(stderr, "./wdt-test -e 0
// Turn off the watchdog timer\n");
fprintf(stderr, "./wdt-test -b 0
// Disable the bypass lan\n");
fprintf(stderr, "./wdt-test -t
// Query watchdog timeout period\n");
fprintf(stderr, "./wdt-test -s 10 // Set watchdog timeout period to 10s\n");
fflush(stderr);
exit(0);
}
fd = open("/dev/watchdog", O_WRONLY);
if (fd == -1)
{
fprintf(stderr, "Watchdog device not enabled.\n");
fflush(stderr);
exit(-1);
}
if (argc > 1)
{
if (!strncasecmp(argv[1], "-e", 2))
{
if(!strncasecmp(argv[2], "1", 1))
{
flags
=
WDIOS_ENABLECARD;
ioctl(fd,
WDIOC_SETOPTIONS,
&flags);
fprintf(stderr,
"Watchdog
card
enabled.\n");
fflush(stderr);
exit(0);
}
if(!strncasecmp(argv[2], "0", 1))