baud-rate

How to set a custom baud rate on Linux?

巧了我就是萌 提交于 2019-11-27 11:47:39
I want to communicate over my serial port on Linux to a device with a non-standard-baud rate that is not defined in termios.h . I tried the "baud rate aliasing"-method from this post , but when I execute my C-program (I’ve named it "testprogram"), Linux says "testprogram sets custom speed on ttyS0. This is deprecated." I did some search on Google, and it seems that there is another (newer?) method to change the baud rate to a non-standard-value: On http://sourceware.org/ml/libc-help/2009-06/msg00016.html the author says that the c_flag of struct termios must be OR’d with BOTHER (=CBAUDEX | B0)

How to set baud rate to 307200 on Linux?

安稳与你 提交于 2019-11-27 01:29:46
Basically I'm using the following code to set the baud rate of a serial port: struct termios options; tcgetattr(fd, &options); cfsetispeed(&options, B115200); cfsetospeed(&options, B115200); tcsetattr(fd, TCSANOW, &options); This works very well. But know I have to communicate with a device that uses a baud rate of 307200. How can I set that? cfsetispeed(&options, B307200); doesn't work, there is no B307200 defined. I tried it using a MOXA Uport 1150 (that's actually a USB-to-serial converter) and the standard serial port of an Intel motherboard. I don't know the exact kind of the latter,