eRPC API Reference  Rev. 1.7.0
NXP Semiconductors
erpc_framed_transport.h
Go to the documentation of this file.
1 /*
2  * The Clear BSD License
3  * Copyright (c) 2014-2016, Freescale Semiconductor, Inc.
4  * Copyright 2016-2017 NXP
5  * All rights reserved.
6  *
7  *
8  * Redistribution and use in source and binary forms, with or without modification,
9  * are permitted (subject to the limitations in the disclaimer below) provided
10  * that the following conditions are met:
11  *
12  * o Redistributions of source code must retain the above copyright notice, this list
13  * of conditions and the following disclaimer.
14  *
15  * o Redistributions in binary form must reproduce the above copyright notice, this
16  * list of conditions and the following disclaimer in the documentation and/or
17  * other materials provided with the distribution.
18  *
19  * o Neither the name of the copyright holder nor the names of its
20  * contributors may be used to endorse or promote products derived from this
21  * software without specific prior written permission.
22  *
23  * NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY THIS LICENSE.
24  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
25  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
27  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
28  * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
31  * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34  */
35 
36 #ifndef _EMBEDDED_RPC__FRAMED_TRANSPORT_H_
37 #define _EMBEDDED_RPC__FRAMED_TRANSPORT_H_
38 
39 #include "erpc_config_internal.h"
40 #include "erpc_message_buffer.h"
41 #include "erpc_transport.h"
42 #include <cstring>
43 
44 #if ERPC_THREADS
45 #include "erpc_threading.h"
46 #endif
47 
54 // Classes
57 
58 namespace erpc {
59 
80 class FramedTransport : public Transport
81 {
82 public:
86  FramedTransport(void);
87 
91  virtual ~FramedTransport(void);
92 
110  virtual erpc_status_t receive(MessageBuffer *message);
111 
120  virtual erpc_status_t send(MessageBuffer *message);
121 
123  struct Header
124  {
125  uint16_t m_messageSize;
126  uint16_t m_crc;
127  };
128 
134  virtual void setCrc16(Crc16 *crcImpl);
135 
136 protected:
139 #if ERPC_THREADS
142 #endif
143 
153  virtual erpc_status_t underlyingSend(const uint8_t *data, uint32_t size) = 0;
154 
164  virtual erpc_status_t underlyingReceive(uint8_t *data, uint32_t size) = 0;
165 };
166 
167 } // namespace erpc
168 
171 #endif // _EMBEDDED_RPC__FRAMED_TRANSPORT_H_
Abstract interface for transport layer.
Definition: erpc_transport.h:61
int32_t erpc_status_t
Type used for all status and error return values.
Definition: erpc_common.h:112
uint16_t m_messageSize
Size in bytes of the message, excluding the header.
Definition: erpc_framed_transport.h:125
Base class for framed transport layers.
Definition: erpc_framed_transport.h:80
virtual erpc_status_t receive(MessageBuffer *message)
Receives an entire message.
Definition: erpc_framed_transport.cpp:65
Contents of the header that prefixes each message.
Definition: erpc_framed_transport.h:123
virtual void setCrc16(Crc16 *crcImpl)
This functions sets the CRC-16 implementation.
Definition: erpc_framed_transport.cpp:59
uint16_t m_crc
CRC-16 over the message data.
Definition: erpc_framed_transport.h:126
virtual ~FramedTransport(void)
Codec destructor.
Definition: erpc_framed_transport.cpp:57
Represents a memory buffer containing a message.
Definition: erpc_message_buffer.h:62
virtual erpc_status_t underlyingReceive(uint8_t *data, uint32_t size)=0
Subclasses must implement this function to receive data.
Mutex m_sendLock
Mutex protecting send.
Definition: erpc_framed_transport.h:140
Definition: erpc_arbitrated_client_manager.h:51
FramedTransport(void)
Constructor.
Definition: erpc_framed_transport.cpp:47
virtual erpc_status_t underlyingSend(const uint8_t *data, uint32_t size)=0
Subclasses must implement this function to send data.
Class for compute crc16.
Definition: erpc_crc16.h:55
Crc16 * m_crcImpl
Definition: erpc_framed_transport.h:137
Mutex m_receiveLock
Mutex protecting receive.
Definition: erpc_framed_transport.h:141
virtual erpc_status_t send(MessageBuffer *message)
Function to send prepared message.
Definition: erpc_framed_transport.cpp:107
Mutex.
Definition: erpc_threading.h:285