![Advantech RSB-4410 User Manual Download Page 48](http://html1.mh-extra.com/html/advantech/rsb-4410/rsb-4410_user-manual_2857964048.webp)
RSB-4410 User Manual
40
if (argc < 2) {
help_info();
return 1;
}
timeout = atoi(argv[1]);
sleep_sec = atoi(argv[2]);
if (sleep_sec <= 0) {
sleep_sec = 1;
printf("correct 0 or negative sleep time to %d seconds\n",
sleep_sec);
}
test = atoi(argv[3]);
printf("Starting wdt_driver (timeout: %d, sleep: %d, test:
%s)\n",
timeout, sleep_sec, (test == 0) ? "ioctl" : "write");
fd = open("/dev/watchdog", O_WRONLY);
if (fd == -1) {
perror("watchdog");
exit(1);
}
printf("Trying to set timeout value=%d seconds\n", timeout);
ioctl(fd, WDIOC_SETTIMEOUT, &timeout);
printf("The actual timeout was set to %d seconds\n",
timeout);
ioctl(fd, WDIOC_GETTIMEOUT, &timeout);
printf("Now reading back -- The timeout is %d seconds\n",
timeout);
while (1) {
printf("WDT Time out counter:%d\n",count);
if ((test !=0) && (test ==count)) {
printf("Ping Watchdog (reset wdt)\n");
ioctl(fd, WDIOC_KEEPALIVE, 0);
test=0;
count=0;
}
sleep(sleep_sec);
count+=sleep_sec;
}
return 0;
}
void help_info(void)
{
printf("Usage: wdt_driver_test <timeout> <sleep>
<trigger>\n");
printf(" timeout: value in seconds to cause wdt timeout/
reset\n");
printf(" sleep: value in seconds to display wdt
timeout\n");
printf(" trigger: value in seconds to ping the wdt\n");
}
If you would like to change the WDT time, please modify:
ioctl(fd, WDIOC_SETTIMEOUT, &timeout).