Moxa V2406-24I-T-XPE [52/81] Device api

Moxa V2422-LX [52/81] Device api
V2406/2422/2426 Linux User’s Manual Programming Guide
4-2
Device API
The V2406/2422/2426-LX supports control devices with the ioctl system API. The interface is shown below:
int ioctl(int d, int request,…);
Input:
<d> open device node return file handle
<request> argument in or out
Refer to desktop Linuxs man page for detailed documentation:
#man ioctl
RTC (Real Time Clock)
The device node is located at /dev/rtc. The V2406/2422/2426-LX 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 the 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 normal tty device nodes are /dev/ttyS0 and /det/ttyS1. The V2406/2422/2426-LX supports standard
Linux termios control with RS-232/422/485 serial ports. Take the following steps to configure the serial ports:
1. You must include moxadevice.h, which you can find in the folder \example\moxalib on the 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.

Содержание

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

Скачать