MC Protocol Serial C++ 0.2.3
MC protocol serial library for MCU-oriented environments
Loading...
Searching...
No Matches
mcprotocol::serial::PosixSerialPort Class Reference

Minimal blocking host-side serial-port wrapper used by the CLI tools. More...

#include <posix_serial.hpp>

Public Member Functions

 PosixSerialPort ()=default
 
 ~PosixSerialPort ()
 
 PosixSerialPort (const PosixSerialPort &)=delete
 
PosixSerialPortoperator= (const PosixSerialPort &)=delete
 
Status open (const PosixSerialConfig &config) noexcept
 Opens and configures the serial port.
 
void close () noexcept
 Closes the serial port if it is open.
 
bool is_open () const noexcept
 Returns whether the serial port is currently open.
 
std::intptr_t native_handle () const noexcept
 Returns the native handle value, or -1 when closed.
 
Status write_all (std::span< const std::byte > bytes) noexcept
 Writes the entire byte range before returning.
 
Status read_some (std::span< std::byte > buffer, int timeout_ms, std::size_t &out_size) noexcept
 Reads up to buffer.size() bytes with a timeout.
 
Status flush_rx () noexcept
 Drops unread RX data that is already buffered by the driver.
 
Status drain_tx () noexcept
 Waits until queued TX data has physically drained.
 
Status set_rts (bool enabled) noexcept
 Sets the RTS line when the underlying driver supports it.
 

Detailed Description

Minimal blocking host-side serial-port wrapper used by the CLI tools.

This class is not required on MCU targets. It exists so the same request/response codec and client logic can be exercised from host-side validation tools.

Definition at line 29 of file posix_serial.hpp.

Constructor & Destructor Documentation

◆ PosixSerialPort() [1/2]

mcprotocol::serial::PosixSerialPort::PosixSerialPort ( )
default

◆ ~PosixSerialPort()

mcprotocol::serial::PosixSerialPort::~PosixSerialPort ( )

◆ PosixSerialPort() [2/2]

mcprotocol::serial::PosixSerialPort::PosixSerialPort ( const PosixSerialPort )
delete

Member Function Documentation

◆ close()

void mcprotocol::serial::PosixSerialPort::close ( )
noexcept

Closes the serial port if it is open.

◆ drain_tx()

Status mcprotocol::serial::PosixSerialPort::drain_tx ( )
noexcept

Waits until queued TX data has physically drained.

◆ flush_rx()

Status mcprotocol::serial::PosixSerialPort::flush_rx ( )
noexcept

Drops unread RX data that is already buffered by the driver.

◆ is_open()

bool mcprotocol::serial::PosixSerialPort::is_open ( ) const
noexcept

Returns whether the serial port is currently open.

◆ native_handle()

std::intptr_t mcprotocol::serial::PosixSerialPort::native_handle ( ) const
noexcept

Returns the native handle value, or -1 when closed.

◆ open()

Status mcprotocol::serial::PosixSerialPort::open ( const PosixSerialConfig config)
noexcept

Opens and configures the serial port.

◆ operator=()

PosixSerialPort & mcprotocol::serial::PosixSerialPort::operator= ( const PosixSerialPort )
delete

◆ read_some()

Status mcprotocol::serial::PosixSerialPort::read_some ( std::span< std::byte buffer,
int  timeout_ms,
std::size_t out_size 
)
noexcept

Reads up to buffer.size() bytes with a timeout.

◆ set_rts()

Status mcprotocol::serial::PosixSerialPort::set_rts ( bool  enabled)
noexcept

Sets the RTS line when the underlying driver supports it.

◆ write_all()

Status mcprotocol::serial::PosixSerialPort::write_all ( std::span< const std::byte bytes)
noexcept

Writes the entire byte range before returning.


The documentation for this class was generated from the following file: