Moxa DA-662A-16-LX [58/63] Baudrate inaccuracy

Moxa DA-662A-I-8-LX [58/63] Baudrate inaccuracy
DA-662A Series Software Programmer's Guide
5-11
Example for getting the baudrate
#include <moxadevice.h>
#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 ) {
// follow the standard termios baudrate define
} else {
ioctl(fd, MOXA_GET_SPECIAL_BAUD_RATE, &speed);
}
Baudrate inaccuracy
Divisor = 921600/Target Baudrate. (Only Integer part)
ENUM = 8 * (921600/Target - Divisor) ( Round up or down)
Inaccuracy = ( (Target Baud Rate 921600/(Divisor + (ENUM/8))) / Target Baud Rate )* 100%
E.g.,
To calculate 500000 bps
Divisor = 1, ENUM = 7,
Inaccuracy = 1.7%
*The Inaccuracy should less than 2% for work reliably.
Special Note
1. If the target baudrate is not a special baudrate (e.g. 50, 75, 110, 134, 150, 200, 300, 600, 1200, 1800,
2400, 4800, 9600, 19200, 38400, 57600, 115200, 230400, 460800, 921600), the termios cflag will be set
to the same flag.
2. If you use stty to get the serial information, you will get speed equal to 0.
LCM
The DA-662A series only supports text mode display, with screen size of 16 cols by 2 rows. The device node is
/dev/lcm. See the examples given below. We provide a private struct defined as follows:
typedef struct lcm_xy {
int x; // col value, the arrange is 0 15
int y; // raw value, the arrange is 0 1
} lcm_xy_t;
Examples
int ioctl(fd, IOCTL_LCM_GOTO_XY, lcm_xy_t *pos);
Move the cursor position to x(col),y(raw) position. The argument 3 is the new position value.
int ioctl(fd, IOCTL_LCM_CLS, NULL);
Clears the LCM display.
int ioctl(fd, IOCTL_LCM_CLEAN_LINE, NULL);
To change one line to all spaces in the current row, and move the cursor to the 0 column of this row.
int ioctl(fd, IOCTL_LCM_GET_XY, lcm_xy_t *pos);
Get the current cursor position. The value will be returned in argument 3.

Содержание

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

Скачать