RADLib
RADical C++ application framework

RADSerial provides event-loop integrated Linux serial port support through RADSerial::RADSerialPort. It is backed by termios and implements RADCore::RADIODevice, posting read availability through a RADCore::EventLoop.

RADSerialPort is constructed with a reference to the EventLoop that receives its events, and raises opened() and closed() events around the port lifecycle. Configure the device path with setPortName() and the line settings with setConfig(), passing a SerialConfig. That struct carries the baudRate (such as 9600, 115200, or 1000000), dataBits, parity, stopBits, and flowControl. Parity is one of Parity::None, Even, or Odd; stop bits are StopBits::One or Two; and flow control is FlowControl::None, Hardware, or Software.

Open the port with open(RADCore::OpenMode) and release it with close(), checking isOpen() as needed. Because the port is a RADIODevice, readData() drains the internal async buffer and writeData() writes to the serial file descriptor. The static listPorts() helper returns likely serial devices under /dev as SerialPortInfo records containing a path and display name.

Core features:

  • Baud rate, data bits, parity, stop bits, and flow control configuration.
  • Async readiness delivery on a RADCore::EventLoop.
  • opened/closed lifecycle events.
  • RADIODevice read/write compatibility.
  • Basic /dev serial port discovery via listPorts().

Example:

port.setPortName("/dev/ttyUSB0");
cfg.baudRate = 115200;
port.setConfig(cfg);
const char* msg = "PING\n";
port.writeData(msg, 5);
}
RADCore task event loop with locked and low-latency scheduling strategies.
Definition: RADCore.h:988
Linux serial port backed by termios and RADCore::RADIODevice.
Definition: RADSerial.h:50
@ ReadWrite
Open for reads and writes.
Serial port configuration.
Definition: RADSerial.h:28
Parity parity
Parity mode.
Definition: RADSerial.h:34
int baudRate
Baud rate such as 9600, 115200, 1000000.
Definition: RADSerial.h:30