UC-7400-LX Plus User’s Manual
Programmer’s Guide
5-9
}
static int swtdfd;
static int stopflag=0;
static void stop_watchdog()
{
stopflag = 1;
}
static void do_watchdog(void)
{
swtd_enable(swtdfd, 500);
while ( stopflag == 0 ) {
mydelay(250);
swtd_ack(swtdfd);
}
swtd_disable(swtdfd);
}
int main(int argc, char *argv[])
{
pid_t sonpid;
signal(SIGUSR1, stop_watchdog);
swtdfd = swtd_open();
if ( swtdfd < 0 ) {
printf(“Open watchdog device fail !\n”);
exit(1);
}
if ( (sonpid=fork()) == 0 )
do_watchdog();
// do user application main function
…..
…..
…..
// end user application
kill(sonpid, SIGUSR1);
swtd_close(swtdfd);
exit(1);
}
The makefile is shown below:
all:
arm-elf-gcc –Wl, -elf2flt –o xxxx xxxx.c –lmoxalib
UART
The normal tty device node is located at
/dev/ttyM0 … ttyM15,
and the modem tty device node is
located at
/dev/cum0 … cum15
.
The UC-7400-LX Plus supports Linux standard termios control. The Moxa UART Device API
allows you to configure ttyM0 to ttyM7 as RS-232, RS-422, 4-wire RS-485, or 2-wire RS-485.
The UC-7400-LX Plus supports RS-232, RS-422, 2-wire RS-485, and 4-wire RS485.
You must use
include <moxadevice.h>
.
#define RS232_MODE
0
#define RS485_2WIRE_MODE
1
#define RS422_MODE
2
#define RS485_4WIRE_MODE
3