compat.libserial
#includeLibSerial — object-oriented C++ serial-port library (SerialPort / SerialStream)
#include <libserial/SerialPort.h>
mcpp add compat.libserial@1.0.0
用法
來自本倉庫自己的測試專案 —— CI 真的編譯並執行過,不是為了網站寫的。
// 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 · 專案 tests/examples/libserial
建置
- targets
serial (lib)- language
c++23- import std
- no
- include dirs
mcpp_generated, */src
原始檔 (3)
*/src/SerialPort.cpp*/src/SerialStream.cpp*/src/SerialStreamBuf.cpp
產生的檔案
mcpp_generated/libserial/SerialPortConstants.h