SSP21-CPP
Public Member Functions | Protected Member Functions | List of all members
ssp21::ILowerLayer Class Referenceabstract

Performs asynchronous RX/TX operations on behalf of an IUpperLayer. More...

#include <ssp21/stack/ILowerLayer.h>

Public Member Functions

virtual bool is_tx_ready () const =0
 Check if the layer is ready to transmit data. More...
 
virtual bool start_tx_from_upper (const seq32_t &data)=0
 Start an asynchronous TX operation. More...
 
seq32_t start_rx_from_upper ()
 Called by the IUpperLayer when it's ready to receive the next chunk of data. More...
 

Protected Member Functions

virtual void discard_rx_data ()=0
 Called when a previous ILowerLayer::start_rx_from_upper() operation completes. More...
 
virtual seq32_t start_rx_from_upper_impl ()=0
 Start reading data. More...
 
void reset_this_lower_layer ()
 Reset the layer. More...
 
bool is_upper_processing_rx () const
 Check if the upper layer is waiting for RX data. More...
 

Detailed Description

Performs asynchronous RX/TX operations on behalf of an IUpperLayer.

This class is used by IStack. User of the library must implement this interface to send and receive the bytes on the wire.

Definition at line 19 of file ILowerLayer.h.

Member Function Documentation

◆ is_tx_ready()

virtual bool ssp21::ILowerLayer::is_tx_ready ( ) const
pure virtual

Check if the layer is ready to transmit data.

Returns
true
if a call to start_tx_from_upper() will succeed,
false
otherwise.

◆ start_tx_from_upper()

virtual bool ssp21::ILowerLayer::start_tx_from_upper ( const seq32_t data)
pure virtual

Start an asynchronous TX operation.

Parameters
dataBytes to be transmitted
Returns
true
if the operation was successfully executed or queued,
false
otherwise.

Once the operation is successfully completed, the implementor must call IUpperLayer::on_lower_tx_ready().

The underlying buffer pointed to by data is loaned out to this layer and must not be mutated until IUpperLayer::on_lower_tx_ready() is called.

◆ start_rx_from_upper()

seq32_t ssp21::ILowerLayer::start_rx_from_upper ( )
inline

Called by the IUpperLayer when it's ready to receive the next chunk of data.

Returns
Slice of received data

The returned slice must remain valid until the next call or until the IUpperLayer is closed.

Implementor of this class must implement ILowerLayer::start_rx_from_upper_impl().

Definition at line 49 of file ILowerLayer.h.

◆ discard_rx_data()

virtual void ssp21::ILowerLayer::discard_rx_data ( )
protectedpure virtual

Called when a previous ILowerLayer::start_rx_from_upper() operation completes.

Notifies that the buffer containing the RX data can be flushed.

◆ start_rx_from_upper_impl()

virtual seq32_t ssp21::ILowerLayer::start_rx_from_upper_impl ( )
protectedpure virtual

Start reading data.

Returns
Slice of data

When bytes arrive, the implementor must call IUpperLayer::on_lower_rx_ready().

The returned slice must remain valid until the next call or until the IUpperLayer is closed.

See ILowerLayer::start_rx_from_upper()

◆ reset_this_lower_layer()

void ssp21::ILowerLayer::reset_this_lower_layer ( )
inlineprotected

Reset the layer.

This method cancels all pending RX and TX operations.

Definition at line 93 of file ILowerLayer.h.

◆ is_upper_processing_rx()

bool ssp21::ILowerLayer::is_upper_processing_rx ( ) const
inlineprotected

Check if the upper layer is waiting for RX data.

Returns
true
if the upper layer is waiting for RX data,
false
otherwise.

Definition at line 102 of file ILowerLayer.h.