Moxa DA-710-XPE [57/73] Define rs232_mode 0 define rs485_2wire_mode 1 define rs422_mode 2 define rs485_4wire_mode 3

Moxa DA-710-XPE [57/73] Define rs232_mode 0 define rs485_2wire_mode 1 define rs422_mode 2 define rs485_4wire_mode 3
DA-710 Series Linux Programmer Guide
4-2
Device API
The DA-710 supports control devices with the ioctl system API. The interface is shown as below.
int ioctl(int d, int request,…);
Input:
<d> open device node return file handle
<request> argument in or out
Refer to desktop Linux’s man page for detailed documentation:
#man ioctl
RTC (Real Time Clock)
The device node is located at /dev/rtc. The DA-710 supports standard Linux simple RTC control. You must
include <linux/rtc.h>.
1. Function: RTC_RD_TIME
int ioctl(fd, RTC_RD_TIME, struct rtc_time *time);
Description: read time information from RTC. It will return the value on argument 3.
2. Function: RTC_SET_TIME
int ioctl(fd, RTC_SET_TIME, struct rtc_time *time);
Description: set RTC time. Argument 3 will be passed to RTC.
UART
The DA-710 supports standard Linux termios control. The Moxa UART Device only supports RS-232 and the
normal tty device node is /dev/ttyS0 and /det/ttyS1.
However, when installed with Moxa’s DA Series Expansion Modules, it can support RS-232, RS-422, 2-wire
RS-485, and 4-wire RS485, depending on the expansion module models. Our system will generate tty device
node as /dev/ttyM0 … /dev/ttyMn. For example, if you have installed the 8-port DA-SP08-I-DB serial
module, the device node will be /dev/ttyM0 to /dev/ttyM7.
To configure the serial ports, follow these steps.
1. You must include “moxadevice.h”, which you can find in the folder \example\moxalib in CD.
#define RS232_MODE 0
#define RS485_2WIRE_MODE 1
#define RS422_MODE 2
#define RS485_4WIRE_MODE 3
2. 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.
3. Function: MOXA_GET_OP_MODE
int ioctl(fd, MOXA_GET_OP_MODE, &mode)
Description Get the interface mode. Argument 3 mode will return the interface mode.
There are two Moxa private ioctl control definitions for setting up special baudrates.
MOXA_SET_SPECIAL_BAUD_RATE
MOXA_GET_SPECIAL_BAUD_RATE
If you use this ioctl to set a special baudrate, the termios cflag will be B4000000, in which case the B4000000
define will be different. If the baudrate you get from termios (or from calling tcgetattr()) is B4000000, you
must call ioctl with MOXA_GET_SPECIAL_BAUD_RATE to get the actual baudrate.

Содержание

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

Скачать