90 explicit serial_port(std::unique_ptr<serial_port_context_interface> ctx);
174 ssize_t
write(std::span<uint8_t> buf)
const;
181 ssize_t
write(std::span<uint8_t> buf, uint32_t ms_timeout)
const;
202 ssize_t
read(std::span<uint8_t> buf);
212 ssize_t
read(std::span<uint8_t> buf, uint32_t ms_timeout);
222 std::unique_ptr<serial_port_context_interface> _impl;
serial_port(std::unique_ptr< serial_port_context_interface > ctx)
Class constructor that allows behaviour customisation.
port_baud_rate baud_rate() const
Current baud rate.
serial_port(const port_attributes &attr, serial_port_receive_fn fn={})
Class constructor which you can specify the port attributes and a receiver callback function.
ssize_t read(std::span< uint8_t > buf)
Read a buffer from a port.
void flush(port_flush_mode mode) const
Flush a port.
ssize_t write(uint8_t value) const
Write a single byte to the port.
void close()
Close the port, resetting its internal value to the initial state.
port_attributes attrs() const
Current port attributes.
void open(const port_attributes &attr, serial_port_receive_fn fn={})
Open a port based on its attributes.
ssize_t write(std::span< uint8_t > buf, uint32_t ms_timeout) const
Tries to write a buffer to a port within an given timeout.
bool is_open() const
Indicates if the port is open or not.
static port_baud_rate to_baud_rate(uint32_t rate)
Converts a number to a port_baud_rate type.
ssize_t read(uint8_t &value)
Read a single byte from a port.
void drain() const
Drain a port.
serial_port()
Default constructor.
ssize_t read(std::span< uint8_t > buf, uint32_t ms_timeout)
Tries to read a buffer from a port within an given timeout.
ssize_t write(std::span< uint8_t > buf) const
Write a buffer to a port.
port_baud_rate
Enumeration of standard baud rates for serial communication.
Definition serial_port_common.h:47
port_flush_mode
Enumeration of serial port flush modes.
Definition serial_port_common.h:120
std::function< void(std::span< uint8_t >)> serial_port_receive_fn
Callback function type for receiving data from a serial port.
Definition serial_port_common.h:35
Any entities that belong to the comms library.
Definition can_adapter.h:12
Serial Port Context Interface.
Structure representing serial port configuration attributes.
Definition serial_port_common.h:177