Advantech RSB-4210 Evaluation Kit User Manual Page 95

  • Download
  • Add to my manuals
  • Print
  • Page
    / 104
  • Table of contents
  • BOOKMARKS
  • Rated. / 5. Based on customer reviews
Page view 94
87 RSB-4210 User Manual
Chapter 3 Software Functionality
3.11.8.3 The ioctl API
All conforming drivers also support an ioctl API.
Pinging the watchdog using an ioctl:
All drivers that have an ioctl interface support at least one ioctl, KEEPALIVE. This
ioctl does exactly the same thing as a write to the watchdog device, so the main loop
in the above program could be replaced with:
while (1) {
ioctl(fd, WDIOC_KEEPALIVE, 0);
sleep(10);
}
the argument to the ioctl is ignored.
Setting and getting the timeout:
For some drivers it is possible to modify the watchdog timeout on the fly with the
SETTIMEOUT ioctl, those drivers have the WDIOF_SETTIMEOUT flag set in their
option field. The argument is an integer representing the timeout in seconds. The
driver returns the real
timeout used in the same variable, and this timeout might differ from the requested
one due to limitation of the hardware.
int timeout = 45;
ioctl(fd, WDIOC_SETTIMEOUT, &timeout);
printf("The timeout was set to %d seconds\n", timeout);
This example might actually print "The timeout was set to 60 seconds" if the device
has a granularity of minutes for its timeout.
Starting with the Linux 2.4.18 kernel, it is possible to query the current timeout using
the GETTIMEOUT ioctl.
ioctl(fd, WDIOC_GETTIMEOUT, &timeout);
printf("The timeout was is %d seconds\n", timeout);
3.11.8.4 Pretimeouts:
Some watchdog timers can be set to have a trigger go off before the actual time they
will reset the system. This can be done with an NMI, interrupt, or other mechanism.
This allows Linux to record useful information (like panic information and kernel core-
dumps) before it resets.
pretimeout = 10;
ioctl(fd, WDIOC_SETPRETIMEOUT, &pretimeout);
Note that the pretimeout is the number of seconds before the time when the timeout
will go off. It is not the number of seconds until the pretimeout. So, for instance, if
you set the timeout to 60 seconds and the pretimeout to 10 seconds, the pretimout
will go of in 50 seconds. Setting a pretimeout to zero disables it.
Page view 94
1 2 ... 90 91 92 93 94 95 96 97 98 99 100 ... 103 104

Comments to this Manuals

No comments