12 How to manage interfaces in Linux
12.15 How the Watchdog is exposed
The ReliaGATE 10-12 exposes the watchdog as follows:
Watchdog: /dev/watchdog1
l
12.15.1
How to manage the Watchdog using the C programming language
To manage the watchdog using the C programming language enter the following commands:
Int interval;
Int bootstatus;
Long value;
/* display current watchdog value */
If (ioctl(fd,WDIOC_GETTIMEOUT,&interval)==0)
{
// interval contains current timeout in seconds
}
/* Check if last boot is caused by watchdog */
If (ioctl(fd,WDIOC_GETBOOTSTATUS,&bootstatus)==0)
{
//bootstatus <> 0 Watchdog
//bootstatus = 0 Power-on reset
}
/* set the watchdog value (for example: 30 seconds) */
value=30;
If (ioctl(fd,WDIOC_SETTIMEOUT,&value)==0)
{
//Watchdog has been set to value content
}
/* stop the watchdog */
write(fd,"V",1);
/* feed the watchdog */
ioctl(fd,WDIOC_KEEPALIVE,0);
12.15.2
How to manage the Watchdog from the command line
To set the watchdog value (for example: 30 seconds), enter the following command:
wdt_setup –d /dev/watchdog1 –t 30
To start and feed the watchdog, enter the following command:
echo 1 > /dev/watchdog1
To stop the watchdog, enter the following command:
echo V > /dev/watchdog1
12.15.3
For more information
For more information on Linux support for watchdog, see:
www.kernel.org/doc/Documentation/watchdog/watchdog-api.txt
88 / 118
ReliaGATE 10-12 User manual Rev. 2-1