Moxa DA-662A-16-LX [54/63] Da 662a series software programmer s guide

Moxa DA-662A-I-8-LX [54/63] Da 662a series software programmer s guide
DA-662A Series Software Programmer's Guide
5-7
3. The user API
The user application must include <moxadevice.h>, and link moxalib.a. A makefile example is shown
below:
all:
arm-none-linux-gnueabi-gcc o xxxx xxxx.c -lmoxalib
int swtd_open(void)
Description
Open the file handle to control the sWatchDog. If you want to do something you must first do this.
And keep the file handle to do other.
Input
None
Output
The return value is a file handle. If there is an error, a negative value (< 0) will be returned.
You can get error from errno().
int swtd_enable(int fd, unsigned long time)
Description
Enable sWatchDog application. You must do an ack after this process.
Input
int fd - the file handle, from the swtd_open() return value.
unsigned long time - The time you wish to ack sWatchDog periodically. You must ack the
sWatchDog before timeout. If you do not ack, the system will reboot automatically. The minimal
time is 50 msec, the maximum time is 60 seconds. The time unit is msec.
Output
If OK, zero will be returned. Nonzero values indicate an error. Get the error code from errno().
int swtd_disable(int fd)
Description
Disable the application to ack sWatchDog. The kernel will perform ack automatically. You do not
need to ack the sWatchdog.
Input
int fd - the file handle from swtd_open() return value.
Output
If OK, zero will be returned. Nonzero values indicate an error. Get the error code from errno().
int swtd_get(int fd, int *mode, unsigned long *time)
Description
Get current setting values.
mode
1 for user application enable sWatchDog: need to do ack.
0 for user application disable sWatchdog: does not need to do ack.
time The time period to ack sWatchDog.
Input
int fd - the file handle from swtd_open() return value.
int *mode - the function will return the status of enable or disable sWatchDog.
unsigned long *time - the function will return the current time period.
Output
If OK, zero will be returned. Nonzero values indicate an error. Get the error code from errno().

Содержание

Похожие устройства

Скачать