Input hardware: BeagleBone Black, with some GNU/Linux distro running on it.
What I want to achieve: I want to set some UART
peripheral to 921600
baud value, and be able to set the other serial-associated settings (e.g. start/stop bits, parity, data bits, hw flow control, etc).
By far, in Linux, I have found at least three ways of configuring this parameters:
- Using
struct termios
formtermios.h
header file. - Using
struct termios2
fromasm/termios.h
header file. - Using the
stty(1)
GNU/Linux utility.
What's the problem:
With the first method I can't use the 921600
baud rate value (there's no define for such higher value, it only goes up to 230400 baud
. So this method won't work.
The second method offers me one way to change custom baud
rate values, but is also tricky because it doesn't offer some functions like tcgetattr()
, tcsendbreak()
, tcflush()
, and so one. This functions are present in the first-described method, and I can't include both header files termios.h
and asm/termios.h
because of (1).
The last method also don't work, or at least it doesn't work for all the settings I want to make. This is the current method I'm using, I'm opening the targeted file, I get one file descriptor, to that file descriptor I set the communication parameters (baud (first i set one lower value), parity, start/stop bits, etc) using the first method, and then I use stty(1)
utility to change (override) the baud rate value to 921600
(I make a system(...)
function call to perform this).
This method won't work if I want to change the HW flow control
for example (it won't override that setting, just like happens with the baud
value).
What are the solutions?
Is it ok to mix two methods of setting parameters to a UART
-communication link like this?