User`s manual
UC-7400-LX Plus User’s Manual Programmer’s Guide
5-7
0 if OK. An error occurs if you see a non-zero value. Use the function errno () to retrieve
the error code.
int swtd_ack(int fd)
Description:
Acknowledge the watchdog. When the user application enables the watchdog, it needs to
call this function periodically with time predefined by the user in the application program.
Input:
int fd — the file handle from the swtd_open() return value.
Output:
0 if OK. An error occurs if you see a non-zero value. Use the function errno () to retrieve
the error code.
int swtd_close(int fd)
Description:
Close the file handle.
Input:
int fd — the file handle from the return value of swtd_open().
Output:
0 if OK. An error occurs if you see a non-zero value. Use the function errno () to retrieve
the error code.
4. Special Note
When you “kill the application with -9” or “kill without option” or “Ctrl+c” the watchdog
function will be changed from user mode to kernel mode.
When your application enables the watchdog and does not acknowledge the WDT, your
application may have a logical error, or your application has made a core dump. Thus, the
watchdog function will not be changed to kernel mode. The WDT waits until the
acknowledgement timeout and force the system to reboot. This can cause a serious problem. If
errors in your application are not fixed, your system will reboot again and again.
5. User application example
Example 1:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <moxadevice.h>
int main(int argc, char *argv[])
{
int fd;
fd = swtd_open();
if ( fd < 0 ) {
printf(“Open watchdog device fail !\n”);
exit(1);
}
swtd_enable(fd, 5000); // enable it and set it 5 seconds
while ( 1 ) {
// do user application want to do
…..
….
swtd_ack(fd);
…..
….
}
swtd_close(fd);