The serial_port_context_interface interface describes the required functions for providing an implementation context for a serial port, meaning the lower level implementation.
This must be inherited if you must provide a custom implementation for the serial_port class.
#include <serial_port_context_interface.h>
|
| virtual void | open (const port_attributes &attr, serial_port_receive_fn fn)=0 |
| | Open a port based on its attributes.
|
|
virtual void | close ()=0 |
| | Close the port, resetting its internal value to the initial state.
|
| virtual bool | is_open () const =0 |
| | Indicates if the port is open or not.
|
| virtual void | flush (port_flush_mode mode)=0 |
| | Flush a port.
|
| virtual void | drain ()=0 |
| | Drain a port.
|
| virtual port_attributes | attrs () const =0 |
| | Current port attributes.
|
| virtual port_baud_rate | baud_rate () const =0 |
| | Current baud rate.
|
| virtual ssize_t | write (uint8_t value)=0 |
| | Write a single byte to the port.
|
| virtual ssize_t | write (std::span< uint8_t > buf)=0 |
| | Write a buffer to a port.
|
| virtual ssize_t | write (std::span< uint8_t > buf, uint32_t ms_timeout)=0 |
| | Tries to write a buffer to a port within an given timeout.
|
| virtual ssize_t | read (uint8_t &value)=0 |
| | Read a single byte from a port.
|
| virtual ssize_t | read (std::span< uint8_t > buf)=0 |
| | Read a buffer from a port.
|
| virtual ssize_t | read (std::span< uint8_t > buf, uint32_t ms_timeout)=0 |
| | Tries to read a buffer from a port within an given timeout.
|
The serial_port_context_interface interface describes the required functions for providing an implementation context for a serial port, meaning the lower level implementation.
This must be inherited if you must provide a custom implementation for the serial_port class.
◆ attrs()
| virtual port_attributes vsdk::comms::serial_port_context_interface::attrs |
( |
| ) |
const |
|
pure virtual |
◆ baud_rate()
| virtual port_baud_rate vsdk::comms::serial_port_context_interface::baud_rate |
( |
| ) |
const |
|
pure virtual |
Current baud rate.
- Returns
- The port baud rate, as defined in port_baud_rate.
◆ drain()
| virtual void vsdk::comms::serial_port_context_interface::drain |
( |
| ) |
|
|
pure virtual |
Drain a port.
Waits until all output written to the object has been transmitted.
◆ flush()
| virtual void vsdk::comms::serial_port_context_interface::flush |
( |
port_flush_mode | mode | ) |
|
|
pure virtual |
Flush a port.
Discards data written to the object referred to by serial_port but not transmitted, or data received but not read.
- Parameters
-
| mode | The queue to be flushed (input, output or both). |
◆ is_open()
| virtual bool vsdk::comms::serial_port_context_interface::is_open |
( |
| ) |
const |
|
pure virtual |
Indicates if the port is open or not.
- Returns
- true if open, else false.
◆ open()
◆ read() [1/3]
| virtual ssize_t vsdk::comms::serial_port_context_interface::read |
( |
std::span< uint8_t > | buf | ) |
|
|
pure virtual |
Read a buffer from a port.
Do not call read if you specified a receive callback.
- Parameters
-
| buf | A std::span<uint8_t> object that contains the data read. |
- Returns
- The amount of data read, -1 on error.
◆ read() [2/3]
| virtual ssize_t vsdk::comms::serial_port_context_interface::read |
( |
std::span< uint8_t > | buf, |
|
|
uint32_t | ms_timeout ) |
|
pure virtual |
Tries to read a buffer from a port within an given timeout.
Do not call read if you specified a receive callback.
- Parameters
-
| buf | A std::span<uint8_t> object that contains the data read. |
| ms_timeout | The timeout in milliseconds. |
- Returns
- The amount of data read, -1 on error.
◆ read() [3/3]
| virtual ssize_t vsdk::comms::serial_port_context_interface::read |
( |
uint8_t & | value | ) |
|
|
pure virtual |
Read a single byte from a port.
Do not call read if you specified a receive callback.
- Parameters
-
- Returns
- The amount of data read, -1 on error
◆ write() [1/3]
| virtual ssize_t vsdk::comms::serial_port_context_interface::write |
( |
std::span< uint8_t > | buf | ) |
|
|
pure virtual |
Write a buffer to a port.
- Parameters
-
| buf | A std::span<uint8_t> object that contains the data to be written. |
- Returns
- The amount of data written, -1 on error, 0 no transmission.
◆ write() [2/3]
| virtual ssize_t vsdk::comms::serial_port_context_interface::write |
( |
std::span< uint8_t > | buf, |
|
|
uint32_t | ms_timeout ) |
|
pure virtual |
Tries to write a buffer to a port within an given timeout.
- Parameters
-
| buf | A std::span<uint8_t> object that contains the data to be written. |
| ms_timeout | The timeout in milliseconds. |
- Returns
- The amount of data written, -1 on error, 0 no transmission.
◆ write() [3/3]
| virtual ssize_t vsdk::comms::serial_port_context_interface::write |
( |
uint8_t | value | ) |
|
|
pure virtual |
Write a single byte to the port.
- Parameters
-
| value | The byte to be written. |
- Returns
- The amount of data written, -1 on error, 0 no transmission.
The documentation for this class was generated from the following file: