mcpp index

compat.libserial

#include

LibSerial — object-oriented C++ serial-port library (SerialPort / SerialStream)

#include <libserial/SerialPort.h>
mcpp add compat.libserial@1.0.0

Usage

From this repository's own test project — built and run by CI, not written for the website.

// Behavioral test: a real pseudo-terminal pair driven through SerialPort.
//
// Why a PTY and not /dev/ttyUSB0: a build machine has no serial hardware, and
// a link-only test would pass even if SerialPort got termios wrong. openpty()
// gives a master/slave pair the same way `socat` would; SerialPort opens the
// slave, and writing on the master exercises its read path while writing
// through SerialPort exercises the master's.
//
// The first include is the one that matters for the descriptor: upstream's
// SerialPortConstants.h uses uint8_t but does not include <cstdint>, so a bare
// `#include <libserial/SerialPort.h>` with nothing before it fails unless the
// package's generated shim supplies it. Deliberately open on the libserial
// header first, with no stdlib header above it, so that shim is compile-time
// asserted.
#ifdef __linux__

#include <libserial/SerialPort.h>
#include <libserial/SerialStream.h>

#include <cassert>
#include <cstdio>
#include <cstring>
// …

tests/examples/libserial/tests/serial.cpp · project tests/examples/libserial

Build

targets
serial (lib)
language
c++23
import std
no
include dirs
mcpp_generated, */src

Sources (3)

  • */src/SerialPort.cpp
  • */src/SerialStream.cpp
  • */src/SerialStreamBuf.cpp

Generated files

  • mcpp_generated/libserial/SerialPortConstants.h

Versions

VersionPlatforms Mirrorssha256
1.0.0 latest Linux CN GLOBAL 063142d6bfe0…