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

用法

来自本仓库自己的测试项目 —— 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

版本

版本平台 镜像sha256
1.0.0 最新 Linux CN GLOBAL 063142d6bfe0…