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

Base class for framed transport layers. More...

#include <erpc_framed_transport.h>

+ 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)
 Codec destructor.
 
virtual erpc_status_t receive (MessageBuffer *message)
 Receives an entire message. More...
 
virtual erpc_status_t send (MessageBuffer *message)
 Function to send prepared message. More...
 
virtual void setCrc16 (Crc16 *crcImpl)
 This functions sets the CRC-16 implementation. 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 (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_messageSize Size in bytes of the message, excluding the header.
uint16_t m_crc CRC-16 over the message data.

Member Function Documentation

erpc_status_t FramedTransport::receive ( MessageBuffer message)
virtual

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)
virtual

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)
virtual

This functions sets the CRC-16 implementation.

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

Reimplemented from erpc::Transport.

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::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::TCPTransport.

Member Data Documentation

Crc16* erpc::FramedTransport::m_crcImpl
protected

CRC object.


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