Moxa IA3341-LX [61/72] Function moxa_set_op_mode

Moxa IA3341-LX [61/72] Function moxa_set_op_mode
IA3341 Linux User’s Manual Programmer’s Guide
6-6
static int swtdfd;
static int stopflag=0;
static void stop_swatchdog()
{
stopflag = 1;
}
static void do_swatchdog(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_swatchdog);
swtdfd = swtd_open();
if ( swtdfd < 0 ) {
printf(“Open sWatchDog device fail !\n”);
exit(1);
}
if ( (sonpid=fork()) == 0 )
do_swatchdog();
// do user application main function
…..
…..
…..
// end user application
kill(sonpid, SIGUSR1);
swtd_close(swtdfd);
exit(1);
}
The makefile is shown below:
all:
arm-linux-gcc –o xxxx xxxx.c –lmoxalib
UART
The normal tty device node is located at
/dev/ttyM0 … ttyM3
.
The IA3341 supports Linux standard termial control. The Moxa UART Device API allows you to
configure ttyM0 to ttyM3 as RS-232, RS-422, 4-wire RS-485, or 2-wire RS-485. IA3341 supports
RS-232, RS-422, 2-wire RS-485, and 4-wire RS-485.
You must
include <moxadevice.h>
.
#define RS232_MODE 0
#define RS485_2WIRE_MODE 1
#define RS422_MODE 2
#define RS485_4WIRE_MODE 3
1. Function: MOXA_SET_OP_MODE
int ioctl(fd, MOXA_SET_OP_MODE, &mode)
Description
Set the interface mode. Argument 3 mode will pass to the UART device driver and change it.

Содержание

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

Скачать