Moxa W406-CE [63/74] Special note

Moxa W406-LX [63/74] Special note
W315A/325A Linux User's Manual Programmer's Guide
6-4
int swtd_enable(int fd, unsigned long time)
Description: Enables the time interval for the WDT. You must provide the time interval (in msec).
Input: <int fd> the file handle; this is the value returned by swtd_open().
<unsigned long time> The time period when ack-ing sWatchDog periodically. You must
acknowledge the WDT before timeout. If you do not acknowledge, the system will reboot
automatically. The minimum time is 50 msec; the maximum time is 60 seconds. The time
unit is msec.
Return Value: 0 (zero) indicates OK; other numbers received indicate an error.
int swtd_disable(int fd)
Description: Disables the WDT.
Input: <int fd> the file handle returned by swtd_open().
Return Value: 0 (zero) indicates OK; other numbers received indicate an error.
int swtd_get(int fd, int *mode, unsigned long *time)
Description: Gets current WDT settings.
Input: <int fd> the file handle returned by swtd_open().
Output: <int mode > the status of the user application (1: WDT is enabled; 0: WDT is disabled)
<unsigned long *time> the current interval time (in msec) for the WDT.
Return Value: 0 (zero) indicates OK; other numbers received indicate an error.
int swtd_ack(int fd)
Description: Acks the WDT.
Input: <int fd> the file handle returned by swtd_open().
Return Value: 0 (zero) indicates OK; other numbers received indicate an error.
int swtd_close(int fd)
Description: Closes the file handle.
Input: <int fd> the file handle returned by swtd_open().
Return Value: 0 (zero) indicates OK; other numbers received indicate an error.
Special Note
When you kill the application with -9” or kill without optionor Ctrl+cthe kernel will change to auto ack the
sWatchDog.
When your application enables the sWatchDog and does not ack, your application may have a logical error, or
your application has made a core dump. The kernel will not change to auto ack. This can cause a serious
problem, causing your system to reboot again and again.
User application examples
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”);

Содержание

Скачать