| eRPC API Reference Rev. 1.8.1 NXP Semiconductors

- Main Page
- API Reference
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

Classes | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
erpc::FramedTransport Class Referenceabstract
Infrastructure » Transports

Base class for framed transport layers. More...

`#include <erpc_framed_transport.h>`

Inheritance diagram for erpc::FramedTransport:
[legend]
Collaboration diagram for erpc::FramedTransport:
[legend]

## 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) 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...
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
Crc16 * | m_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 | ) |
| override 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] | message | Message buffer, to which will be stored incoming message.

Return values

  kErpcStatus_Success | When receiving was successful.
  kErpcStatus_CrcCheckFailed | When receiving failed.
  other | Subclass may return other errors from the underlyingReceive() method.

Implements erpc::Transport.

erpc_status_t FramedTransport::send | ( | MessageBuffer * | message | ) |
| override virtual

Function to send prepared message.

Parameters

  [in] | message | Pass message buffer to send.

Return values

  kErpcStatus_Success | When sending was successful.
  other | Subclass may return other errors from the underlyingSend() method.

Implements erpc::Transport.

void FramedTransport::setCrc16 | ( | Crc16 * | crcImpl | ) |
| override virtual

This functions sets the CRC-16 implementation.

Parameters

  [in] | crcImpl | Object containing crc-16 compute function.

Reimplemented from erpc::Transport.

virtual erpc_status_t erpc::FramedTransport::underlyingSend | ( | const uint8_t * | data,
|  | uint32_t | size
| ) |  |
| protected pure virtual

Subclasses must implement this function to send data.

Parameters

  [in] | data | Buffer to send.
  [in] | size | Size of data to send.

Return values

  kErpcStatus_Success | When data was written successfully.
  kErpcStatus_Fail | When writing data ends with error.

Implemented in erpc::TCPTransport.

virtual erpc_status_t erpc::FramedTransport::underlyingReceive | ( | uint8_t * | data,
|  | uint32_t | size
| ) |  |
| protected pure virtual

Subclasses must implement this function to receive data.

Parameters

  [in,out] | data | Preallocated buffer for receiving data.
  [in] | size | Size of data to read.

Return values

  kErpcStatus_Success | When data was read successfully.
  kErpcStatus_Fail | When 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:

- erpc_framed_transport.h
- erpc_framed_transport.cpp