eRPC API Reference  Rev. 1.12.0
NXP Semiconductors
erpc_framed_transport.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2014-2016, Freescale Semiconductor, Inc.
3  * Copyright 2016-2020 NXP
4  * Copyright 2021 ACRIOS Systems s.r.o.
5  * All rights reserved.
6  *
7  *
8  * SPDX-License-Identifier: BSD-3-Clause
9  */
10 
11 #ifndef _EMBEDDED_RPC__FRAMED_TRANSPORT_H_
12 #define _EMBEDDED_RPC__FRAMED_TRANSPORT_H_
13 
14 #include "erpc_config_internal.h"
15 #include "erpc_message_buffer.hpp"
16 #include "erpc_transport.hpp"
17 
18 #include <cstring>
19 
20 #if !ERPC_THREADS_IS(NONE)
21 #include "erpc_threading.h"
22 #endif
23 
30 // Classes
33 
34 namespace erpc {
35 
56 class FramedTransport : public Transport
57 {
58 public:
60  struct Header
61  {
62  uint16_t m_crcHeader;
63  uint16_t m_messageSize;
64  uint16_t m_crcBody;
65  };
66 
70  FramedTransport(void);
71 
75  virtual ~FramedTransport(void);
76 
82  virtual uint8_t reserveHeaderSize(void) override;
83 
101  virtual erpc_status_t receive(MessageBuffer *message) override;
102 
111  virtual erpc_status_t send(MessageBuffer *message) override;
112 
118  virtual void setCrc16(Crc16 *crcImpl) override;
119 
125  virtual Crc16 *getCrc16(void) override;
126 
127 protected:
130 #if !ERPC_THREADS_IS(NONE)
133 #endif
134 
146  virtual erpc_status_t underlyingSend(MessageBuffer *message, uint32_t size, uint32_t offset);
147 
159  virtual erpc_status_t underlyingReceive(MessageBuffer *message, uint32_t size, uint32_t offset);
160 
170  virtual erpc_status_t underlyingSend(const uint8_t *data, uint32_t size) = 0;
171 
181  virtual erpc_status_t underlyingReceive(uint8_t *data, uint32_t size) = 0;
182 };
183 
184 } // namespace erpc
185 
188 #endif // _EMBEDDED_RPC__FRAMED_TRANSPORT_H_
Abstract interface for transport layer.
Definition: erpc_transport.hpp:36
uint16_t m_crcBody
CRC-16 over the message data.
Definition: erpc_framed_transport.hpp:64
uint16_t m_messageSize
Size in bytes of the message, excluding the header.
Definition: erpc_framed_transport.hpp:63
Base class for framed transport layers.
Definition: erpc_framed_transport.hpp:56
enum _erpc_status erpc_status_t
Type used for all status and error return values.
Definition: erpc_common.h:85
Contents of the header that prefixes each message.
Definition: erpc_framed_transport.hpp:60
virtual ~FramedTransport(void)
FramedTransport destructor.
Definition: erpc_framed_transport.cpp:34
virtual erpc_status_t send(MessageBuffer *message) override
Function to send prepared message.
Definition: erpc_framed_transport.cpp:135
virtual erpc_status_t underlyingReceive(MessageBuffer *message, uint32_t size, uint32_t offset)
Adds ability to framed transport to overwrite MessageBuffer when receiving data.
Definition: erpc_framed_transport.cpp:177
Represents a memory buffer containing a message.
Definition: erpc_message_buffer.hpp:37
Mutex m_sendLock
Mutex protecting send.
Definition: erpc_framed_transport.hpp:131
Definition: erpc_arbitrated_client_manager.hpp:25
FramedTransport(void)
Constructor.
Definition: erpc_framed_transport.cpp:25
virtual Crc16 * getCrc16(void) override
This functions gets the CRC-16 object.
Definition: erpc_framed_transport.cpp:48
Class for compute crc16.
Definition: erpc_crc16.hpp:29
uint16_t m_crcHeader
CRC-16 over this header structure data.
Definition: erpc_framed_transport.hpp:62
virtual uint8_t reserveHeaderSize(void) override
Size of data placed in MessageBuffer before serializing eRPC data.
Definition: erpc_framed_transport.cpp:36
virtual erpc_status_t underlyingSend(MessageBuffer *message, uint32_t size, uint32_t offset)
Adds ability to framed transport to overwrite MessageBuffer when sending data.
Definition: erpc_framed_transport.cpp:170
Crc16 * m_crcImpl
Definition: erpc_framed_transport.hpp:128
virtual void setCrc16(Crc16 *crcImpl) override
This functions sets the CRC-16 implementation.
Definition: erpc_framed_transport.cpp:42
Mutex m_receiveLock
Mutex protecting receive.
Definition: erpc_framed_transport.hpp:132
virtual erpc_status_t receive(MessageBuffer *message) override
Receives an entire message.
Definition: erpc_framed_transport.cpp:53
Mutex.
Definition: erpc_threading.h:339