DA-660-8/16-LXUser’s Manual
Programmer’s Guide
5-7
int swtd_close(int fd)
Description
Close the file handle.
Input
int fd - the file handle from
swtd_open()
return value.
Output
The output will be zero if everything is OK. Any other value indicates an error. Use the
errno() function to get the actual error description.
4.
Special Note
When you kill the application with -9 or kill without any option or kill with a
Ctrl+c
, the
kernel will auto acknowledge the Watch Dog.
When your application enables the Watch Dog and does not acknowledge it, your application
may have a logical error, or your application has made a core dump. The kernel will not auto
acknowledge this. This can cause a serious problem, causing your system to 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 sWatchDog 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);
exit(0);
}
The makefile is shown below:
all:
mxscaleb-gcc –o xxxx xxxx.c –lmoxalib