After spending some hours on Internet I got frustrated about serial communications way to go using C++ running on Linux environments.
It seens there is a lot of options and even some confusion on how to go for it, with a lot of pasted code everywhere with very few explanations about those flags controlling communications behaviour. Things I´ve found includes:
termios.h
: A library that may be obsolete and seens to have com "C" old style coding principle. I could not find a good documentation on that.
boost::serial_port
: The common boost library - a good way to go for those who love it, and a discarded path for those who wants to be "close" to the language and OS as possible (as myself).
Github libraries
: There are some good libraries....
As a serial port works in fact with a stream of bytes I can assume I can built it much like std::cout
and std::cin
, a file
or a stringstream
.
If that is the fact, it should be reasonably straightfoward to build serial communications code: a simple open/close/read/write
would do the job, but then comes port setting (baud rate, parity, etc...), cannonical vs non-cannonical implementation, timeouts, etc...
No that I don´t understand how serial communication works, but I need some advice on where to start from on Linux... I really don´t want to use boost
neither "C" style coding inside C++.
So I ask for suggestions for up-to-dated path to construct my serial communications classes, where I can build a clear C++ code without loosing the communication handling mechanisms needed on a robust implementation.
Modern and up-to-dated docs, examples and opinions are very welcomed...
BTW: I´m using Ubuntu as the OS.