🟨 Synchronous serial port descriptor and configuration
SaneCppSerialPort.h is a library implementing cross-platform serial port open/configuration APIs.
Dependencies

Features
Status
🟨 MVP
The v1 scope focuses on byte-stream descriptors and core serial settings.
Blog
Some relevant blog posts are:
Details
Example
SerialDescriptor serial;
SerialOpenOptions options;
options.settings.baudRate = 115200;
options.settings.dataBits = SerialSettings::DataBits::Bits8;
options.settings.parity = SerialSettings::Parity::None;
options.settings.stopBits = SerialSettings::StopBits::One;
options.settings.flowControl = SerialSettings::FlowControl::None;
#if SC_PLATFORM_WINDOWS
StringView serialPath = "COM3";
#else
StringView serialPath = "/dev/ttyUSB0";
#endif
SC_TRY(serial.open(serialPath, options));
SerialSettings current;
SC_TRY(serial.getSettings(current));
current.baudRate = 57600;
SC_TRY(serial.setSettings(current));
const char tx[] = {'P', 'I', 'N', 'G'};
SC_TRY(serial.write({tx, sizeof(tx)}));
char rxBuffer[64] = {};
Span<char> rxData;
SC_TRY(serial.read({rxBuffer, sizeof(rxBuffer)}, rxData));
Optional Windows Real COM Test (com0com)
SerialPortTest includes an optional section named windows com0com open/config/readback.
- Set
SC_TEST_COM0COM_PORT_A and SC_TEST_COM0COM_PORT_B to enable it.
- Accepted values are both
COMx and \\.\COMx.
- If both variables are unset, the section prints a skip message and succeeds.
- If only one variable is set (or values are malformed), the section fails with a configuration error.
Example command: SC.bat build run SCTest Debug vs2022 -- --test "SerialPortTest" --test-section "windows com0com open/config/readback"
Roadmap
🟩 Usable
- Validate against more USB-to-serial adapters and edge-case drivers.
🟦 Complete Features:
💡 Unplanned Features:
- Port enumeration and hotplug monitoring
Statistics
| Type | Lines Of Code | Comments | Sum |
| Headers | 48 | 40 | 88 |
| Sources | 591 | 76 | 667 |
| Sum | 639 | 116 | 755 |