Skip to content

Commit 8616dbe

Browse files
Feature/support multiple clients (#271)
* Implementing better C++ eRPC support Signed-off-by: Cervenka Dusan <cervenka@acrios.com> * Moving C interface related function declarations into interface header file. Signed-off-by: Cervenka Dusan <cervenka@acrios.com> * Move C generated code into it's own files. Signed-off-by: Cervenka Dusan <cervenka@acrios.com> * Many C++ minor fixes Signed-off-by: Cervenka Dusan <cervenka@acrios.com> * C support multiple clients Signed-off-by: Cervenka Dusan <cervenka@acrios.com> * Tests can be built. Signed-off-by: Cervenka Dusan <cervenka@acrios.com> * Fixed infinity loops in tests (c++ vs c scope) Signed-off-by: Cervenka Dusan <cervenka@acrios.com> * test_callbacks works Signed-off-by: Cervenka Dusan <cervenka@acrios.com> * test_arbitrator is working now Signed-off-by: Cervenka Dusan <cervenka@acrios.com> * Many minor code improvements. Signed-off-by: Cervenka Dusan <cervenka@acrios.com> * Namespace can be defined by user. Default erpcshim Signed-off-by: Cervenka Dusan <cervenka@acrios.com> * Putting function declaration under interface. Signed-off-by: Cervenka Dusan <cervenka@acrios.com> * Refactored code Signed-off-by: Cervenka Dusan <cervenka@acrios.com> * Fixed yml tests. Signed-off-by: Cervenka Dusan <cervenka@acrios.com> * Added c++ enum classes Signed-off-by: Cervenka Dusan <cervenka@acrios.com> * Change based on PR review Signed-off-by: Cervenka Dusan <cervenka@acrios.com> * Revert "Added c++ enum classes" This reverts commit d5acf06. Signed-off-by: Cervenka Dusan <cervenka@acrios.com> * Fixes based on Michal observations Signed-off-by: Cervenka Dusan <cervenka@acrios.com> * Fix wrong name in server function call Signed-off-by: Cervenka Dusan <cervenka@acrios.com> --------- Signed-off-by: Cervenka Dusan <cervenka@acrios.com> Co-authored-by: Michal Princ <michal.princ@nxp.com>
1 parent 7f98fda commit 8616dbe

File tree

140 files changed

+3658
-1599
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

140 files changed

+3658
-1599
lines changed

.clang-format

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ BraceWrapping:
6363
AfterUnion: true
6464
BeforeCatch: true
6565
BeforeElse: true
66-
#IncludeBlocks: "Preserve" # for future version of clang
66+
IncludeBlocks: "Preserve" # for future version of clang
6767
IncludeCategories:
6868
- Regex: "^<" # system includes
6969
Priority: 10

erpc_c/Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ SOURCES += $(ERPC_C_ROOT)/infra/erpc_arbitrated_client_manager.cpp \
6060
$(ERPC_C_ROOT)/infra/erpc_server.cpp \
6161
$(ERPC_C_ROOT)/infra/erpc_simple_server.cpp \
6262
$(ERPC_C_ROOT)/infra/erpc_transport_arbitrator.cpp \
63+
$(ERPC_C_ROOT)/infra/erpc_utils.cpp \
6364
$(ERPC_C_ROOT)/infra/erpc_pre_post_action.cpp \
6465
$(ERPC_C_ROOT)/port/erpc_port_stdlib.cpp \
6566
$(ERPC_C_ROOT)/port/erpc_threading_pthreads.cpp \
@@ -93,6 +94,7 @@ HEADERS += $(ERPC_C_ROOT)/config/erpc_config.h \
9394
$(ERPC_C_ROOT)/infra/erpc_static_queue.hpp \
9495
$(ERPC_C_ROOT)/infra/erpc_transport_arbitrator.hpp \
9596
$(ERPC_C_ROOT)/infra/erpc_transport.hpp \
97+
$(ERPC_C_ROOT)/infra/erpc_utils.hpp \
9698
$(ERPC_C_ROOT)/infra/erpc_client_server_common.hpp \
9799
$(ERPC_C_ROOT)/infra/erpc_pre_post_action.h \
98100
$(ERPC_C_ROOT)/port/erpc_setup_extensions.h \

erpc_c/infra/erpc_arbitrated_client_manager.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ class ArbitratedClientManager : public ClientManager
6363
*
6464
* @return TransportArbitrator * Transport arbitrator instance.
6565
*/
66-
TransportArbitrator *getArbitrator(void) { return m_arbitrator; };
66+
TransportArbitrator * getArbitrator(void) { return m_arbitrator; };
6767

6868
protected:
6969
TransportArbitrator *m_arbitrator; //!< Optional transport arbitrator. May be NULL.

erpc_c/infra/erpc_basic_codec.cpp

Lines changed: 0 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -161,37 +161,6 @@ void BasicCodec::writeNullFlag(bool isNull)
161161
write(static_cast<uint8_t>(isNull ? null_flag_t::kIsNull : null_flag_t::kNotNull));
162162
}
163163

164-
void BasicCodec::writeCallback(arrayOfFunPtr callbacks, uint8_t callbacksCount, funPtr callback)
165-
{
166-
uint8_t i;
167-
168-
erpc_assert(callbacksCount > 1U);
169-
170-
// callbacks = callbacks table
171-
for (i = 0; i < callbacksCount; i++)
172-
{
173-
if (callbacks[i] == callback)
174-
{
175-
write(i);
176-
break;
177-
}
178-
if ((i + 1U) == callbacksCount)
179-
{
180-
updateStatus(kErpcStatus_UnknownCallback);
181-
}
182-
}
183-
}
184-
185-
void BasicCodec::writeCallback(funPtr callback1, funPtr callback2)
186-
{
187-
// callbacks = callback directly
188-
// When declared only one callback function no serialization is needed.
189-
if (callback1 != callback2)
190-
{
191-
updateStatus(kErpcStatus_UnknownCallback);
192-
}
193-
}
194-
195164
void BasicCodec::startReadMessage(message_type_t &type, uint32_t &service, uint32_t &request, uint32_t &sequence)
196165
{
197166
uint32_t header;
@@ -396,34 +365,6 @@ void BasicCodec::readNullFlag(bool &isNull)
396365
}
397366
}
398367

399-
void BasicCodec::readCallback(arrayOfFunPtr callbacks, uint8_t callbacksCount, funPtr *callback)
400-
{
401-
uint8_t _tmp_local;
402-
403-
erpc_assert(callbacksCount > 1U);
404-
405-
// callbacks = callbacks table
406-
read(_tmp_local);
407-
if (isStatusOk())
408-
{
409-
if (_tmp_local < callbacksCount)
410-
{
411-
*callback = callbacks[_tmp_local];
412-
}
413-
else
414-
{
415-
*callback = NULL;
416-
m_status = kErpcStatus_UnknownCallback;
417-
}
418-
}
419-
}
420-
421-
void BasicCodec::readCallback(funPtr callbacks1, funPtr *callback2)
422-
{
423-
// callbacks = callback directly
424-
*callback2 = callbacks1;
425-
}
426-
427368
ERPC_MANUALLY_CONSTRUCTED_ARRAY_STATIC(BasicCodec, s_basicCodecManual, ERPC_CODEC_COUNT);
428369

429370
Codec *BasicCodecFactory::create(void)

erpc_c/infra/erpc_basic_codec.hpp

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -189,23 +189,6 @@ class BasicCodec : public Codec
189189
* @param[in] isNull Null flag to send.
190190
*/
191191
virtual void writeNullFlag(bool isNull) override;
192-
193-
/*!
194-
* @brief Writes an order ID of callback function.
195-
*
196-
* @param[in] callbacks Pointer to array of callbacks.
197-
* @param[in] callbacksCount Size of array of callbacks.
198-
* @param[in] callback Callback which ID should be serialized.
199-
*/
200-
virtual void writeCallback(arrayOfFunPtr callbacks, uint8_t callbacksCount, funPtr callback) override;
201-
202-
/*!
203-
* @brief Writes an order ID of callback function.
204-
*
205-
* @param[in] callback1 Pointer to existing callback.
206-
* @param[out] callback2 Callback which ID should be serialized.
207-
*/
208-
virtual void writeCallback(funPtr callback1, funPtr callback2) override;
209192
//@}
210193

211194
//! @name Decoding
@@ -350,23 +333,6 @@ class BasicCodec : public Codec
350333
* @param[in] isNull Null flag to read.
351334
*/
352335
virtual void readNullFlag(bool &isNull) override;
353-
354-
/*!
355-
* @brief Read an callback function id and return address of callback function.
356-
*
357-
* @param[in] callbacks Pointer to array of callbacks.
358-
* @param[in] callbacksCount Size of array of callbacks.
359-
* @param[out] callback Callback which is deserialized. Null in case of error.
360-
*/
361-
virtual void readCallback(arrayOfFunPtr callbacks, uint8_t callbacksCount, funPtr *callback) override;
362-
363-
/*!
364-
* @brief Read an callback function id and return address of callback function.
365-
*
366-
* @param[in] callback1 Pointer to existing callback.
367-
* @param[out] callback2 Callback which is deserialized.
368-
*/
369-
virtual void readCallback(funPtr callbacks1, funPtr *callback2) override;
370336
//@}
371337
};
372338

erpc_c/infra/erpc_client_manager.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
*/
2626

2727
extern "C" {
28+
#else
29+
#include "erpc_common.h"
2830
#endif
2931

3032
typedef void (*client_error_handler_t)(erpc_status_t err,

erpc_c/infra/erpc_client_server_common.hpp

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
#ifndef _EMBEDDED_RPC__CLIENTSERVERCOMMON_H_
1111
#define _EMBEDDED_RPC__CLIENTSERVERCOMMON_H_
1212

13-
#include "erpc_config_internal.h"
1413
#include "erpc_codec.hpp"
14+
#include "erpc_config_internal.h"
1515
#if ERPC_MESSAGE_LOGGING
1616
#include "erpc_message_loggers.hpp"
1717
#endif
@@ -66,7 +66,7 @@ class ClientServerCommon
6666
#endif
6767
#if ERPC_MESSAGE_LOGGING
6868
#ifdef ERPC_OTHER_INHERITANCE
69-
,
69+
,
7070
#else
7171
#define ERPC_OTHER_INHERITANCE 1
7272
:
@@ -75,20 +75,23 @@ class ClientServerCommon
7575
#endif
7676
#if ERPC_PRE_POST_ACTION
7777
#ifdef ERPC_OTHER_INHERITANCE
78-
,
78+
,
7979
#else
8080
#define ERPC_OTHER_INHERITANCE 1
8181
:
8282
#endif
8383
PrePostAction()
8484
#endif
8585
#ifdef ERPC_OTHER_INHERITANCE
86-
,
86+
,
8787
#else
8888
#define ERPC_OTHER_INHERITANCE 1
8989
:
9090
#endif
91-
m_messageFactory(NULL), m_codecFactory(NULL), m_transport(NULL){};
91+
m_messageFactory(NULL)
92+
, m_codecFactory(NULL)
93+
, m_transport(NULL)
94+
{};
9295

9396
/*!
9497
* @brief ClientServerCommon destructor

erpc_c/infra/erpc_codec.hpp

Lines changed: 1 addition & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
#include "erpc_message_buffer.hpp"
1616
#include "erpc_transport.hpp"
1717

18+
#include <cstdint>
1819
#include <cstring>
19-
#include <stdint.h>
2020

2121
/*!
2222
* @addtogroup infra_codec
@@ -257,23 +257,6 @@ class Codec
257257
* @param[in] isNull Null flag to send.
258258
*/
259259
virtual void writeNullFlag(bool isNull) = 0;
260-
261-
/*!
262-
* @brief Writes an order ID of callback function.
263-
*
264-
* @param[in] callbacks Pointer to array of callbacks.
265-
* @param[in] callbacksCount Size of array of callbacks.
266-
* @param[in] callback Callback which ID should be serialized.
267-
*/
268-
virtual void writeCallback(arrayOfFunPtr callbacks, uint8_t callbacksCount, funPtr callback) = 0;
269-
270-
/*!
271-
* @brief Writes an order ID of callback function.
272-
*
273-
* @param[in] callback1 Pointer to existing callback.
274-
* @param[out] callback2 Callback which ID should be serialized.
275-
*/
276-
virtual void writeCallback(funPtr callback1, funPtr callback2) = 0;
277260
//@}
278261

279262
//! @name Decoding
@@ -410,23 +393,6 @@ class Codec
410393
*/
411394
virtual void readNullFlag(bool &isNull) = 0;
412395

413-
/*!
414-
* @brief Read an callback function id and return address of callback function.
415-
*
416-
* @param[in] callbacks Pointer to array of callbacks.
417-
* @param[in] callbacksCount Size of array of callbacks.
418-
* @param[out] callback Callback which is deserialized. Null in case of error.
419-
*/
420-
virtual void readCallback(arrayOfFunPtr callbacks, uint8_t callbacksCount, funPtr *callback) = 0;
421-
422-
/*!
423-
* @brief Read an callback function id and return address of callback function.
424-
*
425-
* @param[in] callback1 Pointer to existing callback.
426-
* @param[out] callback2 Callback which is deserialized.
427-
*/
428-
virtual void readCallback(funPtr callbacks1, funPtr *callback2) = 0;
429-
430396
protected:
431397
MessageBuffer m_buffer; /*!< Message buffer object */
432398
MessageBuffer::Cursor m_cursor; /*!< Copy data to message buffers. */

erpc_c/infra/erpc_framed_transport.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ class FramedTransport : public Transport
114114
*
115115
* @return Crc16* Pointer to CRC-16 object containing crc-16 compute function.
116116
*/
117-
virtual Crc16 *getCrc16() override;
117+
virtual Crc16 *getCrc16(void) override;
118118

119119
protected:
120120
Crc16 *m_crcImpl; /*!< CRC object. */

erpc_c/infra/erpc_manually_constructed.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ class ManuallyConstructed
161161
* @brief Returns information if object is free or is used.
162162
*
163163
* @return true Object is constructed and used.
164-
* @return false Object wasn't constructer or it is destructed and free.
164+
* @return false Object wasn't constructed or it was destructed already.
165165
*/
166166
bool isUsed(void) { return m_isConstructed; }
167167

0 commit comments

Comments
 (0)