Moxa V2426A-C2-W7E [23/88] Configuring serial port mode

Moxa V2426A-C2-CT-T [23/88] Configuring serial port mode
V2400A Series Expansion Modules Software Installation and Programming Guide
4-3
Example: Viewing the Modulation Rate/Baudrate
#define MOXA 0x400
#define MOXA_SET_SPECIAL_BAUD_RATE (MOXA+100)
#define MOXA_GET_SPECIAL_BAUD_RATE (MOXA+101)
#include <termios.h>
struct termios term;
int fd, speed;
fd = open(“/dev/ttyM0”, O_RDWR);
tcgetattr(fd, &term);
if ( (term.c_cflag & (CBAUD|CBAUDEX)) != B4000000 ) {
// On this line, you may insert a standard baud rate
} else {
ioctl(fd, MOXA_GET_SPECIAL_BAUD_RATE, &speed);
}
ATTENTION
The m
aximum baudrate for the serial ports is 921,600 bps. The serial port expansion module supports
modulation rates
of up to 921,600 baud. Standard baudrate
s are: 50, 75, 110, 134, 150, 200, 300, 600, 1200,
1800,
2400, 4800, 9600, 19200, 38400, 57600, 115200, 230400, 460800, and 921600. To configure the
above code for a standard baud
rate connection, simply insert the number on the indicated line.
If you use
stty to get interface stats from a connection configured for a non-
standard baud, the system will
return a rate of 0.
Modulation Rate Inaccuracy
If you want to use to a non-standard baudrate, use the following equation to calculate the baudrate tolerance
to minimize signal errors:
*** Inaccuracy = (Target Baudrate 921600/(Divisor + (ENUM/8))) / Target Baudrate * 100%
The variables in the above equation are described below:
Divisor = Integer part of [921,600 / Target Baudrate]
ENUM = 8 * (921600 / Target baudrate - Divisor) (Round up or down)
E.g., to calculate the inaccuracy for 500,000 bps:
Divisor = 1, ENUM = 7,
Inaccuracy = 1.7%
Note: For reliable performance, the inaccuracy should be less than 2%
Configuring Serial Port Mode
Use the setinterface command to retrieve the parameters of the serial port configuration. The usage is
$:~# setinterface [device node] [interface option]. The device node is the tty device to be
configured. For the serial ports, Moxa uses a proprietary driver whose device nodes are identified with the
marker M. Serial ports 1 and 2 (respectively) on card 1 are referred to as ttyM0 and ttyM1, and ttyM8 and
ttyM9 refer to ports 1 and 2 (respectively) on the second card. The interface option is a number between 0
and 4 that will determine what serial interface should be configured for the port in question. For example,
$:~# setinterface /dev/ttyM0 0
This command sets the first serial port on the first card for RS-232 communications as shown in the following
example:

Содержание

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

Скачать