Moxa TC-SW04-M12-4P-T [24/43] Tc sp04 db44 t configuring the baudrate

Moxa TC-SW04-M12-4P-T [24/43] Tc sp04 db44 t configuring the baudrate
TC-6000 Series Expansion Modules Software Installation and Programming Guide
4-4
WARNING
If you use
the stty command to get interface stats from a connection configured for a non-standard baudrate
,
the system will return a rate of 0.
TC-SP04-DB44-T: Configuring the Baudrate
Example Script #1: Setting the 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/ttyM8”, O_RDWR);
tcgetattr(fd, &term);
term.c_cflag &= ~(CBAUD | CBAUDEX);
term.c_cflag |= B4000000;
tcsetattr(fd, TCSANOW, &term);
speed = 115200;
ioctl(fd, MOXA_SET_SPECIAL_BAUD_RATE, &speed);
Example Script #2: Return the 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/ttyM8”, 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);
}
Non-Standard Baudrates and Baudrate Inaccuracy
Moxa’s drivers allow engineers to configure our serial devices for non-standard baudrates. Theoretically, these
devices may be set for any baudrate; however, in practice the only non-standard rates that will communicate
at the chosen baudrate are whole number factors of the base rate, 921,600 bps. For any non-standard rates
that are not a whole number factor of 921,600, there will be some inaccuracy in transmission speed relative to
the configured rate.
Standard baudrates are 50, 75, 110, 134, 150, 200, 300, 600, 1200, 1800, 2400, 4800, 9600, 19200, 38400,
57600, 115200, 230400, 460800, and 921600. Moxa’s drivers allow for any whole number factor of 921,600 to
be used without any performance loss (i.e., inaccuracy or deviation from the TBR) in the configured modulation
rate. To calculate the relative inaccuracy for non-standard baudrates that are not a whole number factor of
921,600, use the formula below:

Содержание

Скачать