eRPC API Reference  Rev. 1.7.0
NXP Semiconductors
erpc_transport_arbitrator.h
Go to the documentation of this file.
1 /*
2  * The Clear BSD License
3  * Copyright (c) 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 #if !defined(__embedded_rpc__transport_arbitrator__)
36 #define __embedded_rpc__transport_arbitrator__
37 
38 #include "erpc_client_manager.h"
39 #include "erpc_codec.h"
40 #include "erpc_threading.h"
41 #include "erpc_transport.h"
42 
49 // Classes
52 
53 namespace erpc {
54 class Codec;
55 
67 {
68 public:
70  typedef uintptr_t client_token_t;
71 
75  TransportArbitrator(void);
76 
80  virtual ~TransportArbitrator(void);
81 
87  void setSharedTransport(Transport *shared) { m_sharedTransport = shared; }
88 
94  void setCodec(Codec *codec) { m_codec = codec; }
95 
97  virtual erpc_status_t receive(MessageBuffer *message);
98 
106  client_token_t prepareClientReceive(RequestContext &request);
107 
114  erpc_status_t clientReceive(client_token_t token);
115 
117  virtual erpc_status_t send(MessageBuffer *message);
118 
124  virtual void setCrc16(Crc16 *crcImpl);
125 
126 protected:
129 
134  {
137  bool m_isValid;
143  PendingClientInfo(void);
144 
148  ~PendingClientInfo(void);
149  };
150 
154 
161 
168 
174  void freeClientList(PendingClientInfo *list);
175 };
176 
177 } // namespace erpc
178 
181 #endif // defined(__embedded_rpc__transport_arbitrator__)
182 // EOF
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
Interposer to share transport between client and server.
Definition: erpc_transport_arbitrator.h:66
~PendingClientInfo(void)
Destructor.
Definition: erpc_transport_arbitrator.cpp:249
erpc_status_t clientReceive(client_token_t token)
Receive method for the client.
Definition: erpc_transport_arbitrator.cpp:153
Abstract serialization encoder/decoder interface.
Definition: erpc_codec.h:76
client_token_t prepareClientReceive(RequestContext &request)
Add a client request to the client list.
Definition: erpc_transport_arbitrator.cpp:141
virtual erpc_status_t receive(MessageBuffer *message)
Receive method for the server.
Definition: erpc_transport_arbitrator.cpp:71
PendingClientInfo * addPendingClient(void)
This function adds pending client.
Definition: erpc_transport_arbitrator.cpp:168
Request info for a client trying to receive a response.
Definition: erpc_transport_arbitrator.h:133
PendingClientInfo(void)
Constructor.
Definition: erpc_transport_arbitrator.cpp:241
bool m_isValid
Definition: erpc_transport_arbitrator.h:137
Transport * m_sharedTransport
Transport being shared through this arbitrator.
Definition: erpc_transport_arbitrator.h:127
void freeClientList(PendingClientInfo *list)
This function removes pending client list.
Definition: erpc_transport_arbitrator.cpp:230
PendingClientInfo * m_clientFreeList
Unused client receive info structs.
Definition: erpc_transport_arbitrator.h:152
Represents a memory buffer containing a message.
Definition: erpc_message_buffer.h:62
Definition: erpc_arbitrated_client_manager.h:51
PendingClientInfo * m_next
Definition: erpc_transport_arbitrator.h:138
virtual void setCrc16(Crc16 *crcImpl)
This functions sets the CRC-16 implementation.
Definition: erpc_transport_arbitrator.cpp:64
void removePendingClient(PendingClientInfo *info)
This function removes pending client.
Definition: erpc_transport_arbitrator.cpp:198
virtual ~TransportArbitrator(void)
Destructor.
Definition: erpc_transport_arbitrator.cpp:57
Class for compute crc16.
Definition: erpc_crc16.h:55
RequestContext * m_request
Definition: erpc_transport_arbitrator.h:135
void setCodec(Codec *codec)
This function set codec.
Definition: erpc_transport_arbitrator.h:94
virtual erpc_status_t send(MessageBuffer *message)
Shared client/server send method.
Definition: erpc_transport_arbitrator.cpp:135
PendingClientInfo * m_clientList
Active client receive requests.
Definition: erpc_transport_arbitrator.h:151
Codec * m_codec
Codec used to read incoming message headers.
Definition: erpc_transport_arbitrator.h:128
Mutex m_clientListMutex
Mutex guarding the client active and free lists.
Definition: erpc_transport_arbitrator.h:153
void setSharedTransport(Transport *shared)
This function set shared client/server transport.
Definition: erpc_transport_arbitrator.h:87
Semaphore m_sem
Definition: erpc_transport_arbitrator.h:136
TransportArbitrator(void)
Constructor.
Definition: erpc_transport_arbitrator.cpp:47
uintptr_t client_token_t
Represents a single client's receive request.
Definition: erpc_transport_arbitrator.h:70
Mutex.
Definition: erpc_threading.h:285
Simple semaphore class.
Definition: erpc_threading.h:385
Encapsulates all information about a request.
Definition: erpc_client_manager.h:245