eRPC API Reference  Rev. 1.12.0
NXP Semiconductors
erpc::FramedTransport Class Referenceabstract

Base class for framed transport layers. More...

#include <erpc_framed_transport.hpp>

+ Inheritance diagram for erpc::FramedTransport:
+ Collaboration diagram for erpc::FramedTransport:

Classes

struct  Header
 Contents of the header that prefixes each message. More...
 

Public Member Functions

 FramedTransport (void)
 Constructor.
 
virtual ~FramedTransport (void)
 FramedTransport destructor.
 
virtual uint8_t reserveHeaderSize (void) override
 Size of data placed in MessageBuffer before serializing eRPC data. More...
 
virtual erpc_status_t receive (MessageBuffer *message) override
 Receives an entire message. More...
 
virtual erpc_status_t send (MessageBuffer *message) override
 Function to send prepared message. More...
 
virtual void setCrc16 (Crc16 *crcImpl) override
 This functions sets the CRC-16 implementation. More...
 
virtual Crc16getCrc16 (void) override
 This functions gets the CRC-16 object. More...
 
- Public Member Functions inherited from erpc::Transport
 Transport (void)
 Constructor.
 
virtual ~Transport (void)
 Transport destructor.
 
virtual bool hasMessage (void)
 Poll for an incoming message. More...
 

Protected Member Functions

virtual erpc_status_t underlyingSend (MessageBuffer *message, uint32_t size, uint32_t offset)
 Adds ability to framed transport to overwrite MessageBuffer when sending data. More...
 
virtual erpc_status_t underlyingReceive (MessageBuffer *message, uint32_t size, uint32_t offset)
 Adds ability to framed transport to overwrite MessageBuffer when receiving data. More...
 
virtual erpc_status_t underlyingSend (const uint8_t *data, uint32_t size)=0
 Subclasses must implement this function to send data. More...
 
virtual erpc_status_t underlyingReceive (uint8_t *data, uint32_t size)=0
 Subclasses must implement this function to receive data. More...
 

Protected Attributes

Crc16m_crcImpl
 
Mutex m_sendLock
 Mutex protecting send.
 
Mutex m_receiveLock
 Mutex protecting receive.
 

Detailed Description

Base class for framed transport layers.

This class adds simple framing to the data transmitted and received on the communications channel. This allows the transport to perform reads and writes of a size known in advance. Subclasses must implement the underlyingSend() and underlyingReceive() methods to actually transmit and receive data.

Frames have a maximum size of 64kB, as a 16-bit frame size is used.

Note
This implementation currently assumes both sides of the communications channel are the same endianness.

The frame header includes a CRC-16 over the data for integrity checking. This class includes a default CRC-16 implementation that is optimized for code size, but is relatively slow. If a faster implementation is desired, you can pass the new CRC function to setCRCFunction().


Class Documentation

struct erpc::FramedTransport::Header

Contents of the header that prefixes each message.

Class Members
uint16_t m_crcHeader CRC-16 over this header structure data.
uint16_t m_messageSize Size in bytes of the message, excluding the header.
uint16_t m_crcBody CRC-16 over the message data.

Member Function Documentation

uint8_t FramedTransport::reserveHeaderSize ( void  )
overridevirtual

Size of data placed in MessageBuffer before serializing eRPC data.

Returns
uint8_t Amount of bytes, reserved before serialized data.

Reimplemented from erpc::Transport.

erpc_status_t FramedTransport::receive ( MessageBuffer message)
overridevirtual

Receives an entire message.

The frame header and message data are received. The CRC-16 in the frame header is compared with the computed CRC. If the received CRC is invalid, kErpcStatus_Fail will be returned.

The message is only filled with the message data, not the frame header.

This function is blocking.

Parameters
[in]messageMessage buffer, to which will be stored incoming message.
Return values
kErpcStatus_SuccessWhen receiving was successful.
kErpcStatus_CrcCheckFailedWhen receiving failed.
otherSubclass may return other errors from the underlyingReceive() method.

Implements erpc::Transport.

erpc_status_t FramedTransport::send ( MessageBuffer message)
overridevirtual

Function to send prepared message.

Parameters
[in]messagePass message buffer to send.
Return values
kErpcStatus_SuccessWhen sending was successful.
otherSubclass may return other errors from the underlyingSend() method.

Implements erpc::Transport.

void FramedTransport::setCrc16 ( Crc16 crcImpl)
overridevirtual

This functions sets the CRC-16 implementation.

Parameters
[in]crcImplObject containing crc-16 compute function.

Reimplemented from erpc::Transport.

Crc16 * FramedTransport::getCrc16 ( void  )
overridevirtual

This functions gets the CRC-16 object.

Returns
Crc16* Pointer to CRC-16 object containing crc-16 compute function.

Reimplemented from erpc::Transport.

erpc_status_t FramedTransport::underlyingSend ( MessageBuffer message,
uint32_t  size,
uint32_t  offset 
)
protectedvirtual

Adds ability to framed transport to overwrite MessageBuffer when sending data.

Usually we don't want to do that.

Parameters
messageMessageBuffer to send.
sizesize of message to send.
offsetdata start address offset
Returns
erpc_status_t kErpcStatus_Success when it finished successful otherwise error.

Reimplemented in erpc::RPMsgTTYRTOSTransport.

erpc_status_t FramedTransport::underlyingReceive ( MessageBuffer message,
uint32_t  size,
uint32_t  offset 
)
protectedvirtual

Adds ability to framed transport to overwrite MessageBuffer when receiving data.

Usually we don't want to do that.

Parameters
messageMessageBuffer to send.
sizesize of message to send.
offsetdata start address offset
Returns
erpc_status_t kErpcStatus_Success when it finished successful otherwise error.

Reimplemented in erpc::RPMsgTTYRTOSTransport.

virtual erpc_status_t erpc::FramedTransport::underlyingSend ( const uint8_t *  data,
uint32_t  size 
)
protectedpure virtual

Subclasses must implement this function to send data.

Parameters
[in]dataBuffer to send.
[in]sizeSize of data to send.
Return values
kErpcStatus_SuccessWhen data was written successfully.
kErpcStatus_FailWhen writing data ends with error.

Implemented in erpc::RPMsgTTYRTOSTransport, and erpc::TCPTransport.

virtual erpc_status_t erpc::FramedTransport::underlyingReceive ( uint8_t *  data,
uint32_t  size 
)
protectedpure virtual

Subclasses must implement this function to receive data.

Parameters
[in,out]dataPreallocated buffer for receiving data.
[in]sizeSize of data to read.
Return values
kErpcStatus_SuccessWhen data was read successfully.
kErpcStatus_FailWhen reading data ends with error.

Implemented in erpc::RPMsgTTYRTOSTransport, and erpc::TCPTransport.

Member Data Documentation

Crc16* erpc::FramedTransport::m_crcImpl
protected

CRC object.


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