39
edits
Changes
From IGEP - ISEE Wiki
no edit summary
The watchdog can be configured by editing the underlying device parameters of special files. It can easily be implemented inside our simple test with ''ioctl()''.
====Timeout====
For example, we can change the timeout value by adding the following lines to our main function, before the ''while'' loop:
Note too that the timeout can be set to 60 seconds depending on the device's granularity.
We can also request the timeout value by using the following commands:
ioctl(fd, WDIOC_GETTIMEOUT, &timeout);
printf("The timeout value is %d seconds\n", timeout);
====Pretimeout====
If your watchdog supports pretimeout, you can set the time lapse between the pretimeout and the timeout:
pretimeout = 10;
ioctl(fd, WDIOC_SETPRETIMEOUT, &pretimeout);
It can be useful for recording useful information and/or saving the data that the program was handling before rebooting the machine.
We can also request the timeout value by using the following commands:
ioctl(fd, WDIOC_GETPRETIMEOUT, &pretimeout);
printf("The pretimeout value is %d seconds\n", pretimeout);
====Time left====
Some watchdog drivers can report the remaining time before the system will reboot. With these lines we can ask the driver for the number of seconds remaining before timeout:
ioctl(fd, WDIOC_GETTIMELEFT, &timeleft);
printf("The time left is %d seconds\n", timeleft);
<center>''Work in progress, for more information on WD parameters please read [http://www.kernel.org/doc/Documentation/watchdog/watchdog-api.txt Linux Watchdog driver API.]''</center>
[[Category:Software]]