Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
0d758ed
Assert costumizing #143
willmann9527 Nov 3, 2020
5201990
test
willmann9527 Jan 26, 2022
dd1f826
Merge remote-tracking branch 'origin/develop' into Assert_costumizing…
willmann9527 Jan 26, 2022
8565311
Fixed failed build.
willmann9527 Jan 26, 2022
dfc4045
Added missing include
willmann9527 Jan 26, 2022
639d72a
Copied customized assert to all other config files.
willmann9527 Jan 26, 2022
973987e
Improved erpc_assert config
willmann9527 Jan 26, 2022
c984d28
Separate user and internal settings.
willmann9527 Jan 27, 2022
9048321
Removed redundant includes and fix add a missing include.
willmann9527 Jan 27, 2022
5615682
Update erpc_mu_transport.h
willmann9527 Jan 27, 2022
71aa1a8
Removed erpc_config.h includes.
willmann9527 Jan 27, 2022
31980ac
Update erpc_mu_transport.h
willmann9527 Jan 27, 2022
a862597
Move erpc_assert definition to bottom
Hadatko Jan 28, 2022
d6d1940
Added assert support for mbed os.
Hadatko Jan 28, 2022
806814b
Use generic erpc_assert implementation
Hadatko Jan 28, 2022
9b667eb
Added missing endif into macro condition
Hadatko Jan 28, 2022
c515837
Added support for Freertos configASSERT
Hadatko Jan 28, 2022
309d547
Fixed c vs c++ include
Hadatko Jan 31, 2022
17c30e8
Update assert
Hadatko Jan 31, 2022
0e62039
Update assert
Hadatko Jan 31, 2022
2af43b1
Update assert
Hadatko Jan 31, 2022
bb0e967
Update assert
Hadatko Jan 31, 2022
c194193
Update assert
Hadatko Jan 31, 2022
d13143c
Update assert
Hadatko Jan 31, 2022
3f52e89
Update support for Freertos configASSERT
MichalPrincNXP Jan 31, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions erpc_c/config/erpc_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,13 @@
//! Uncomment for using pre post default callback feature.
//#define ERPC_PRE_POST_ACTION_DEFAULT (ERPC_PRE_POST_ACTION_DEFAULT_ENABLED)

//! @name Assert function definition
//@{
//! User custom asser defition. Include header file if needed before bellow line. If assert is not enabled, default will be used.
// #define erpc_assert(condition)
//@}


/*! @} */
#endif // _ERPC_CONFIG_H_
////////////////////////////////////////////////////////////////////////////////
Expand Down
4 changes: 1 addition & 3 deletions erpc_c/infra/erpc_arbitrated_client_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
#include "erpc_arbitrated_client_manager.h"
#include "erpc_transport_arbitrator.h"

#include "assert.h"

#if ERPC_THREADS_IS(NONE)
#error "Arbitrator code does not work in no-threading configuration."
#endif
Expand Down Expand Up @@ -42,7 +40,7 @@ void ArbitratedClientManager::performClientRequest(RequestContext &request)
erpc_status_t err;
TransportArbitrator::client_token_t token = 0;

assert(m_arbitrator && "arbitrator not set");
erpc_assert(m_arbitrator && "arbitrator not set");

// Set up the client receive before we send the request, so if the reply is sent
// before we get to the clientReceive() call below the arbitrator already has the buffer.
Expand Down
4 changes: 2 additions & 2 deletions erpc_c/infra/erpc_basic_codec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ void BasicCodec::writeCallback(arrayOfFunPtr callbacks, uint8_t callbacksCount,
{
uint8_t i;

assert(callbacksCount > 1U);
erpc_assert(callbacksCount > 1U);

// callbacks = callbacks table
for (i = 0; i < callbacksCount; i++)
Expand Down Expand Up @@ -352,7 +352,7 @@ void BasicCodec::readCallback(arrayOfFunPtr callbacks, uint8_t callbacksCount, f
{
uint8_t _tmp_local;

assert(callbacksCount > 1U);
erpc_assert(callbacksCount > 1U);

// callbacks = callbacks table
read(&_tmp_local);
Expand Down
8 changes: 3 additions & 5 deletions erpc_c/infra/erpc_client_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@

#include "erpc_client_manager.h"

#include "assert.h"

using namespace erpc;

////////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -49,7 +47,7 @@ void ClientManager::performRequest(RequestContext &request)
#if ERPC_NESTED_CALLS
if (performRequest)
{
assert(m_serverThreadId && "server thread id was not set");
erpc_assert(m_serverThreadId && "server thread id was not set");
if (Thread::getCurrentThreadId() == m_serverThreadId)
{
performNestedClientRequest(request);
Expand Down Expand Up @@ -120,7 +118,7 @@ void ClientManager::performNestedClientRequest(RequestContext &request)
{
erpc_status_t err;

assert(m_transport && "transport/arbitrator not set");
erpc_assert(m_transport && "transport/arbitrator not set");

#if ERPC_MESSAGE_LOGGING
if (request.getCodec()->isStatusOk() == true)
Expand All @@ -143,7 +141,7 @@ void ClientManager::performNestedClientRequest(RequestContext &request)
// Receive reply.
if (request.getCodec()->isStatusOk() == true)
{
assert(m_server && "server for nesting calls was not set");
erpc_assert(m_server && "server for nesting calls was not set");
err = m_server->run(request);
request.getCodec()->updateStatus(err);
}
Expand Down
7 changes: 3 additions & 4 deletions erpc_c/infra/erpc_framed_transport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
#include "erpc_framed_transport.h"
#include "erpc_message_buffer.h"

#include <cassert>
#include <cstdio>

using namespace erpc;
Expand All @@ -34,7 +33,7 @@ FramedTransport::~FramedTransport(void) {}

void FramedTransport::setCrc16(Crc16 *crcImpl)
{
assert(crcImpl);
erpc_assert(crcImpl);
m_crcImpl = crcImpl;
}

Expand All @@ -44,7 +43,7 @@ erpc_status_t FramedTransport::receive(MessageBuffer *message)
erpc_status_t retVal;
uint16_t computedCrc;

assert(m_crcImpl && "Uninitialized Crc16 object.");
erpc_assert(m_crcImpl && "Uninitialized Crc16 object.");

{
#if !ERPC_THREADS_IS(NONE)
Expand Down Expand Up @@ -102,7 +101,7 @@ erpc_status_t FramedTransport::send(MessageBuffer *message)
uint16_t messageLength;
Header h;

assert(m_crcImpl && "Uninitialized Crc16 object.");
erpc_assert(m_crcImpl && "Uninitialized Crc16 object.");

#if !ERPC_THREADS_IS(NONE)
Mutex::Guard lock(m_sendLock);
Expand Down
12 changes: 6 additions & 6 deletions erpc_c/infra/erpc_message_buffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
*/

#include "erpc_message_buffer.h"
#include "erpc_config_internal.h"

#include <cassert>
#include <cstring>

using namespace erpc;
Expand Down Expand Up @@ -64,7 +64,7 @@ erpc_status_t MessageBuffer::write(uint16_t offset, const void *data, uint32_t l

erpc_status_t MessageBuffer::copy(const MessageBuffer *other)
{
assert(m_len >= other->m_len);
erpc_assert(m_len >= other->m_len);

m_used = other->m_used;
(void)memcpy(m_buf, other->m_buf, m_used);
Expand All @@ -74,7 +74,7 @@ erpc_status_t MessageBuffer::copy(const MessageBuffer *other)

void MessageBuffer::swap(MessageBuffer *other)
{
assert(other);
erpc_assert(other);

MessageBuffer temp(*other);

Expand All @@ -90,15 +90,15 @@ void MessageBuffer::Cursor::set(MessageBuffer *buffer)
{
m_buffer = buffer;
// RPMSG when nested calls are enabled can set NULL buffer.
// assert(buffer->get() && "Data buffer wasn't set to MessageBuffer.");
// erpc_assert(buffer->get() && "Data buffer wasn't set to MessageBuffer.");
// receive function should return err if it couldn't set data buffer.
m_pos = buffer->get();
m_remaining = buffer->getLength();
}

erpc_status_t MessageBuffer::Cursor::read(void *data, uint32_t length)
{
assert(m_pos && "Data buffer wasn't set to MessageBuffer.");
erpc_assert(m_pos && "Data buffer wasn't set to MessageBuffer.");

erpc_status_t err;

Expand All @@ -120,7 +120,7 @@ erpc_status_t MessageBuffer::Cursor::read(void *data, uint32_t length)

erpc_status_t MessageBuffer::Cursor::write(const void *data, uint32_t length)
{
assert(m_pos && "Data buffer wasn't set to MessageBuffer.");
erpc_assert(m_pos && "Data buffer wasn't set to MessageBuffer.");

erpc_status_t err;

Expand Down
2 changes: 0 additions & 2 deletions erpc_c/infra/erpc_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@

#include "erpc_server.h"

#include "assert.h"

using namespace erpc;

////////////////////////////////////////////////////////////////////////////////
Expand Down
15 changes: 7 additions & 8 deletions erpc_c/infra/erpc_transport_arbitrator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,9 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
#include "erpc_transport_arbitrator.h"

#include "erpc_config_internal.h"
#include "erpc_manually_constructed.h"

#include <cassert>
#include <cstdio>
#include <string>

Expand Down Expand Up @@ -47,21 +46,21 @@ TransportArbitrator::~TransportArbitrator(void)

void TransportArbitrator::setCrc16(Crc16 *crcImpl)
{
assert(crcImpl);
assert(m_sharedTransport);
erpc_assert(crcImpl);
erpc_assert(m_sharedTransport);
m_sharedTransport->setCrc16(crcImpl);
}

bool TransportArbitrator::hasMessage(void)
{
assert(m_sharedTransport && "shared transport is not set");
erpc_assert(m_sharedTransport && "shared transport is not set");

return m_sharedTransport->hasMessage();
}

erpc_status_t TransportArbitrator::receive(MessageBuffer *message)
{
assert(m_sharedTransport && "shared transport is not set");
erpc_assert(m_sharedTransport && "shared transport is not set");

erpc_status_t err;
message_type_t msgType;
Expand Down Expand Up @@ -142,7 +141,7 @@ erpc_status_t TransportArbitrator::receive(MessageBuffer *message)

erpc_status_t TransportArbitrator::send(MessageBuffer *message)
{
assert(m_sharedTransport && "shared transport is not set");
erpc_assert(m_sharedTransport && "shared transport is not set");
return m_sharedTransport->send(message);
}

Expand All @@ -159,7 +158,7 @@ TransportArbitrator::client_token_t TransportArbitrator::prepareClientReceive(Re

erpc_status_t TransportArbitrator::clientReceive(client_token_t token)
{
assert((token != 0) && "invalid client token");
erpc_assert((token != 0) && "invalid client token");

// Convert token to pointer to info struct for this client receive request.
PendingClientInfo *info = reinterpret_cast<PendingClientInfo *>(token);
Expand Down
60 changes: 42 additions & 18 deletions erpc_c/port/erpc_config_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,13 @@

// Detect allocation policy if not already set.
#if !defined(ERPC_ALLOCATION_POLICY)
#if defined(__has_include) && __has_include("FreeRTOSConfig.h")
#if ERPC_HAS_FREERTOSCONFIG_H
#ifdef __cplusplus
extern "C" {
extern "C" {
#endif
#include "FreeRTOSConfig.h"
#ifdef __cplusplus
}
}
#endif
#if defined(configSUPPORT_STATIC_ALLOCATION) && configSUPPORT_STATIC_ALLOCATION
#define ERPC_ALLOCATION_POLICY (ERPC_ALLOCATION_POLICY_STATIC)
Expand All @@ -68,15 +68,15 @@
#endif

#if ERPC_ALLOCATION_POLICY == ERPC_ALLOCATION_POLICY_STATIC
#if !defined(ERPC_CODEC_COUNT)
#define ERPC_CODEC_COUNT (2U)
#endif
#if !defined(ERPC_MESSAGE_LOGGERS_COUNT)
#define ERPC_MESSAGE_LOGGERS_COUNT (0U)
#endif
#if !defined(ERPC_CLIENTS_THREADS_AMOUNT)
#define ERPC_CLIENTS_THREADS_AMOUNT (1U)
#endif
#if !defined(ERPC_CODEC_COUNT)
#define ERPC_CODEC_COUNT (2U)
#endif
#if !defined(ERPC_MESSAGE_LOGGERS_COUNT)
#define ERPC_MESSAGE_LOGGERS_COUNT (0U)
#endif
#if !defined(ERPC_CLIENTS_THREADS_AMOUNT)
#define ERPC_CLIENTS_THREADS_AMOUNT (1U)
#endif
#endif

// Safely detect tx_api.h.
Expand Down Expand Up @@ -133,9 +133,9 @@

//NOEXCEPT support
#if defined(__cplusplus) && __cplusplus >= 201103 && ERPC_NOEXCEPT
#define NOEXCEPT noexcept
#define NOEXCEPT noexcept
#else
#define NOEXCEPT
#define NOEXCEPT
#endif // NOEXCEPT

// Disabling nesting calls support as default.
Expand All @@ -162,11 +162,11 @@
#endif

#if defined(__CC_ARM) || defined(__ARMCC_VERSION) /* Keil MDK */
#define THROW_BADALLOC throw(std::bad_alloc)
#define THROW throw()
#define THROW_BADALLOC throw(std::bad_alloc)
#define THROW throw()
#else
#define THROW_BADALLOC
#define THROW
#define THROW_BADALLOC
#define THROW
#endif

#ifndef ERPC_TRANSPORT_MU_USE_MCMGR
Expand Down Expand Up @@ -195,6 +195,30 @@
#define ERPC_PRE_POST_ACTION_DEFAULT (ERPC_PRE_POST_ACTION_DEFAULT_DISABLED)
#endif

#if !defined(erpc_assert)
#if ERPC_HAS_FREERTOSCONFIG_H
#ifdef __cplusplus
extern "C" {
#endif
#include "FreeRTOS.h"
#include "task.h"
#ifdef __cplusplus
}
#endif
#define erpc_assert(condition) configASSERT(condition)
#elif defined(ERPC_THREADS) && (ERPC_THREADS == ERPC_THREADS_MBED)
#include "platform/mbed_assert.h"
#define erpc_assert(condition) MBED_ASSERT(condition)
#else
#ifdef __cplusplus
#include <cassert>
#else
#include "assert.h"
#endif
#define erpc_assert(condition) assert(condition)
#endif
#endif

/* clang-format on */
#endif // _ERPC_DETECT_H_
////////////////////////////////////////////////////////////////////////////////
Expand Down
Loading