Veethree D7 SDK
Loading...
Searching...
No Matches
vsdk::comms::serial_port_context_interface Class Referenceabstract

Detailed Description

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>

Public Member Functions

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.

Detailed Description

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.

Member Function Documentation

◆ attrs()

virtual port_attributes vsdk::comms::serial_port_context_interface::attrs ( ) const
pure virtual

Current port attributes.

Returns
The port attributes, see port_attributes.

◆ 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
modeThe 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()

virtual void vsdk::comms::serial_port_context_interface::open ( const port_attributes & attr,
serial_port_receive_fn fn )
pure virtual

Open a port based on its attributes.

Parameters
attrThe port attributes, see port_attributes.
fnThe receive callback,
See also
serial_port_receive_fn.

◆ 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
bufA 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
bufA std::span<uint8_t> object that contains the data read.
ms_timeoutThe 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
valueThe value read.
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
bufA 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
bufA std::span<uint8_t> object that contains the data to be written.
ms_timeoutThe 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
valueThe 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: