Moxa V2401-CE [65/108] Device api

Moxa V2401-CE [65/108] Device api
V2401/2402 Series Linux User’s Manual Programmer Guide
4-2
Device API
The V2401/2402 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
RTC (Real Time Clock)
The device node is located at /dev/rtc. The V2401/2402 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 normal tty device node is /dev/ttyS0 and /det/ttyS1.
The V2401/2402 supports standard Linux termios control with RS-232/422/485 serial ports.
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.

Содержание

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

Скачать