Header-only serial library for Windows and Linux.
A POD type that holds information about the serial port.
An object of this type is produced by open and must be passed through to all other functions.
A POD type that holds:
- Baud rate ->
int - Character size ->
int:5-8 - Flow control ->
enum class FlowControl:NONE|SOFTWARE|HARDWARE - Parity ->
enum class Parity:NONE|ODD|EVEN - Stop bits ->
enum class StopBits:ONE|ONE_POINT_FIVE|TWO
An object of this type should be provided to the configure to apply the settings to an open serial port.
The type has sane defaults that apply to most devices.
Usually the only thing that needs changing is the baud rate.
Provide a valid path to a serial port device and a SerialPort object will be returned.
After opening a port, it should be configured. Usually the only setting that needs to be changed is the baud rate.
Sets the device latency to 1ms if low_latency is true.
Return the number of bytes waiting to be read off the serial port.
Discard all data that is currently waiting to be read from the port.
Discard all data that is waiting to be written to the port.
Read bytes from the serial port.
The buf should be at least length in size.
Timeout:
0: the read will not block but return instantly with the number of bytes read. The buffer will be filled by any bytes read.-1: the read will block untillengthbytes have been read.> 0: the read will block until eitherlengthbytes have been read, ortimeoutmilliseconds have passed.
Write bytes to serial port.
Again, the buf should be at least length in size.
The rules for timeout are the same as with read.