Skip to content

Commit

Permalink
eRPC updates 01/2022
Browse files Browse the repository at this point in the history
-- Allow used LIBUSBSIO device index being specified from the Python command line argument.
-- Remove obsolete python test files.
-- Minor Misra and typo corrections.
-- Update license file.
  • Loading branch information
MichalPrincNXP committed Jan 10, 2022
1 parent 99675ec commit 56393df
Show file tree
Hide file tree
Showing 87 changed files with 723 additions and 426 deletions.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Copyright 2014-2016 Freescale Semiconductor, Inc.
Copyright 2016-2021 NXP
Copyright 2016-2022 NXP
All rights reserved.

The BSD 3 Clause License
Expand Down
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -189,11 +189,10 @@ eRPC code is validated with respect to the C++ 11 standard.

### Installing for Python

To install the Python infrastructure for eRPC, first change to the `erpc_python/` directory. Then run the setup.py script like this:
To install the Python infrastructure for eRPC see instructions in the [erpc_python folder readme](erpc_python/readme.md).

python setup.py install

After installation, the `erpc` package is available via normal import statements. See the [erpc_python folder readme](erpc_python/readme.md) for more.
## Known issues and limitations
- Static allocations controlled by the ERPC_ALLOCATION_POLICY config macro are not fully supported yet, i.e. not all erpc objects can be allocated statically now. It deals with the ongoing process and the full static allocations support will be added in the future.

## Code providing

Expand Down
2 changes: 1 addition & 1 deletion doxygen/Doxyfile.erpc
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ PROJECT_NAME = "eRPC API Reference"
# could be handy for archiving the generated documentation or if some version
# control system is used.

PROJECT_NUMBER = "Rev. 1.8.1"
PROJECT_NUMBER = "Rev. 1.9.0"

# Using the PROJECT_BRIEF tag one can provide an optional one line description
# for a project that appears at the top of each page and should give viewer a
Expand Down
2 changes: 1 addition & 1 deletion doxygen/Doxyfile.erpcgen
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ PROJECT_NAME = "eRPC Generator (erpcgen)"
# could be handy for archiving the generated documentation or if some version
# control system is used.

PROJECT_NUMBER = "Rev. 1.8.1"
PROJECT_NUMBER = "Rev. 1.9.0"

# Using the PROJECT_BRIEF tag one can provide an optional one line description
# for a project that appears at the top of each page and should give viewer a
Expand Down
16 changes: 8 additions & 8 deletions erpc_c/config/erpc_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,17 +66,17 @@
//! Set ERPC_ALLOCATION_POLICY_DYNAMIC if dynamic allocations should be used.
//! Set ERPC_ALLOCATION_POLICY_STATIC if static allocations should be used.
//!
//! Default value is ERPC_ALLOCATION_POLICY_DYNAMIC or in case of FreeRTOS it can be auto-detected if __has_include() is supported
//! by compiler. Uncomment comment bellow to use static allocation policy.
//! In case of static implementation user need consider another values to set (ERPC_CODEC_COUNT,
//! ERPC_MESSAGE_LOGGERS_COUNT, ERPC_CLIENTS_THREADS_AMOUNT).
//! Default value is ERPC_ALLOCATION_POLICY_DYNAMIC or in case of FreeRTOS it can be auto-detected if __has_include() is
//! supported by compiler. Uncomment comment bellow to use static allocation policy. In case of static implementation
//! user need consider another values to set (ERPC_CODEC_COUNT, ERPC_MESSAGE_LOGGERS_COUNT,
//! ERPC_CLIENTS_THREADS_AMOUNT).
// #define ERPC_ALLOCATION_POLICY (ERPC_ALLOCATION_POLICY_STATIC)

//! @def ERPC_CODEC_COUNT
//!
//! @brief Set amount of codecs objects used simultaneously in case of ERPC_ALLOCATION_POLICY is set to
//! ERPC_ALLOCATION_POLICY_STATIC. For example if client or server is used in one thread then 1. If both are used in one thread per
//! each then 2, ... Default value 2.
//! ERPC_ALLOCATION_POLICY_STATIC. For example if client or server is used in one thread then 1. If both are used in one
//! thread per each then 2, ... Default value 2.
// #define ERPC_CODEC_COUNT (2U)

//! @def ERPC_MESSAGE_LOGGERS_COUNT
Expand All @@ -90,8 +90,8 @@

//! @def ERPC_CLIENTS_THREADS_AMOUNT
//!
//! @brief Set amount of client threads objects used in case of ERPC_ALLOCATION_POLICY is set to ERPC_ALLOCATION_POLICY_STATIC.
//! Default value 1 (Most of current cases).
//! @brief Set amount of client threads objects used in case of ERPC_ALLOCATION_POLICY is set to
//! ERPC_ALLOCATION_POLICY_STATIC. Default value 1 (Most of current cases).
// #define ERPC_CLIENTS_THREADS_AMOUNT (1U)

//! @def ERPC_THREADS
Expand Down
1 change: 0 additions & 1 deletion erpc_c/infra/erpc_arbitrated_client_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
*/

#include "erpc_arbitrated_client_manager.h"

#include "erpc_transport_arbitrator.h"

#include "assert.h"
Expand Down
27 changes: 13 additions & 14 deletions erpc_c/infra/erpc_basic_codec.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Copyright (c) 2014, Freescale Semiconductor, Inc.
* Copyright 2016-2017 NXP
* Copyright 2016-2021 NXP
* Copyright 2021 ACRIOS Systems s.r.o.
* All rights reserved.
*
Expand All @@ -9,7 +9,6 @@
*/

#include "erpc_basic_codec.h"

#include "erpc_manually_constructed.h"

#if ERPC_ALLOCATION_POLICY == ERPC_ALLOCATION_POLICY_DYNAMIC
Expand All @@ -23,11 +22,11 @@ using namespace erpc;
// Code
////////////////////////////////////////////////////////////////////////////////

const uint8_t BasicCodec::kBasicCodecVersion = 1;
const uint32_t BasicCodec::kBasicCodecVersion = 1UL;

void BasicCodec::startWriteMessage(message_type_t type, uint32_t service, uint32_t request, uint32_t sequence)
{
uint32_t header = (kBasicCodecVersion << 24) | ((service & 0xff) << 16) | ((request & 0xff) << 8) | (type & 0xff);
uint32_t header = (kBasicCodecVersion << 24u) | ((service & 0xffu) << 16u) | ((request & 0xffu) << 8u) | ((uint32_t)type & 0xffu);

write(header);

Expand All @@ -36,7 +35,7 @@ void BasicCodec::startWriteMessage(message_type_t type, uint32_t service, uint32

void BasicCodec::writeData(const void *value, uint32_t length)
{
if (!m_status)
if (isStatusOk())
{
if (value != NULL)
{
Expand All @@ -52,7 +51,7 @@ void BasicCodec::writeData(const void *value, uint32_t length)
void BasicCodec::write(bool value)
{
// Make sure the bool is a single byte.
uint8_t v = value;
uint8_t v = (uint8_t)value;

writeData(&v, sizeof(v));
}
Expand Down Expand Up @@ -109,7 +108,7 @@ void BasicCodec::write(double value)

void BasicCodec::writePtr(uintptr_t value)
{
uint8_t ptrSize = sizeof(value);
uint8_t ptrSize = (uint8_t)sizeof(value);

write(ptrSize);

Expand Down Expand Up @@ -189,7 +188,7 @@ void BasicCodec::startReadMessage(message_type_t *type, uint32_t *service, uint3
updateStatus(kErpcStatus_InvalidMessageVersion);
}

if (!m_status)
if (isStatusOk())
{
*service = ((header >> 16) & 0xffU);
*request = ((header >> 8) & 0xffU);
Expand All @@ -201,7 +200,7 @@ void BasicCodec::startReadMessage(message_type_t *type, uint32_t *service, uint3

void BasicCodec::readData(void *value, uint32_t length)
{
if (!m_status)
if (isStatusOk())
{
if (value != NULL)
{
Expand All @@ -219,9 +218,9 @@ void BasicCodec::read(bool *value)
uint8_t v = 0;

readData(&v, sizeof(v));
if (!m_status)
if (isStatusOk())
{
*value = v;
*value = (bool)v;
}
}

Expand Down Expand Up @@ -299,15 +298,15 @@ void BasicCodec::readBinary(uint32_t *length, uint8_t **value)
// Read length first as u32.
read(length);

if (!m_status)
if (isStatusOk())
{
if (m_cursor.getRemaining() >= *length)
{
// Return current pointer into buffer.
*value = m_cursor.get();

// Skip over data.
m_cursor += *length;
m_cursor += (uint16_t)*length;
}
else
{
Expand Down Expand Up @@ -378,7 +377,7 @@ void BasicCodec::readCallback(funPtr callbacks1, funPtr *callback2)

ERPC_MANUALLY_CONSTRUCTED_ARRAY_STATIC(BasicCodec, s_basicCodecManual, ERPC_CODEC_COUNT);

Codec *BasicCodecFactory ::create()
Codec *BasicCodecFactory ::create(void)
{
ERPC_CREATE_NEW_OBJECT(BasicCodec, s_basicCodecManual, ERPC_CODEC_COUNT)
}
Expand Down
4 changes: 2 additions & 2 deletions erpc_c/infra/erpc_basic_codec.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Copyright (c) 2014, Freescale Semiconductor, Inc.
* Copyright 2016-2017 NXP
* Copyright 2016-2021 NXP
* Copyright 2021 ACRIOS Systems s.r.o.
* All rights reserved.
*
Expand Down Expand Up @@ -41,7 +41,7 @@ enum _null_flag
class BasicCodec : public Codec
{
public:
static const uint8_t kBasicCodecVersion; /*!< Codec version. */
static const uint32_t kBasicCodecVersion; /*!< Codec version. */

BasicCodec(void)
: Codec()
Expand Down
4 changes: 2 additions & 2 deletions erpc_c/infra/erpc_client_manager.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Copyright (c) 2014, Freescale Semiconductor, Inc.
* Copyright 2016-2017 NXP
* Copyright 2016-2021 NXP
* Copyright 2021 ACRIOS Systems s.r.o.
* All rights reserved.
*
Expand Down Expand Up @@ -197,7 +197,7 @@ Codec *ClientManager::createBufferAndCodec(void)
if (codec != NULL)
{
message = m_messageFactory->create();
if (message.get())
if (NULL != message.get())
{
codec->setBuffer(message);
}
Expand Down
4 changes: 2 additions & 2 deletions erpc_c/infra/erpc_codec.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Copyright (c) 2014, Freescale Semiconductor, Inc.
* Copyright 2016-2017 NXP
* Copyright 2016-2021 NXP
* Copyright 2021 ACRIOS Systems s.r.o.
* All rights reserved.
*
Expand Down Expand Up @@ -118,7 +118,7 @@ class Codec
*/
void updateStatus(erpc_status_t status)
{
if (!m_status)
if (isStatusOk())
{
m_status = status;
}
Expand Down
6 changes: 3 additions & 3 deletions erpc_c/infra/erpc_crc16.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2017 NXP
* Copyright 2021 NXP
* Copyright 2021 ACRIOS Systems s.r.o.
* All rights reserved.
*
Expand Down Expand Up @@ -44,15 +44,15 @@ uint16_t Crc16::computeCRC16(const uint8_t *data, uint32_t lengthInBytes)
for (i = 0; i < 8U; ++i)
{
temp = crc << 1;
if (crc & andValue)
if (0UL != (crc & andValue))
{
temp ^= xorValue;
}
crc = temp;
}
}

return crc;
return (uint16_t)crc;
}
void Crc16::setCrcStart(uint32_t crcStart)
{
Expand Down
1 change: 0 additions & 1 deletion erpc_c/infra/erpc_framed_transport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
*/

#include "erpc_framed_transport.h"

#include "erpc_message_buffer.h"

#include <cassert>
Expand Down
2 changes: 1 addition & 1 deletion erpc_c/infra/erpc_framed_transport.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class FramedTransport : public Transport
FramedTransport(void);

/*!
* @brief Codec destructor
* @brief FramedTransport destructor
*/
virtual ~FramedTransport(void);

Expand Down
2 changes: 1 addition & 1 deletion erpc_c/infra/erpc_manually_constructed.h
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ class ManuallyConstructed
* @return true Object is constructed and used.
* @return false Object wasn't constructer or it is destructed and free.
*/
bool isUsed() { return m_isConstructed; }
bool isUsed(void) { return m_isConstructed; }

protected:
/*!
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
@@ -1,6 +1,6 @@
/*
* Copyright (c) 2014-2016, Freescale Semiconductor, Inc.
* Copyright 2016 NXP
* Copyright 2016-2021 NXP
* Copyright 2021 ACRIOS Systems s.r.o.
* All rights reserved.
*
Expand Down Expand Up @@ -32,7 +32,7 @@ erpc_status_t MessageBuffer::read(uint16_t offset, void *data, uint32_t length)
{
if (length > 0U)
{
memcpy(data, &m_buf[offset], length);
(void)memcpy(data, &m_buf[offset], length);
}

err = kErpcStatus_Success;
Expand All @@ -53,7 +53,7 @@ erpc_status_t MessageBuffer::write(uint16_t offset, const void *data, uint32_t l
{
if (length > 0U)
{
memcpy(m_buf, data, length);
(void)memcpy(m_buf, data, length);
}

err = kErpcStatus_Success;
Expand All @@ -67,7 +67,7 @@ erpc_status_t MessageBuffer::copy(const MessageBuffer *other)
assert(m_len >= other->m_len);

m_used = other->m_used;
memcpy(m_buf, other->m_buf, m_used);
(void)memcpy(m_buf, other->m_buf, m_used);

return kErpcStatus_Success;
}
Expand Down Expand Up @@ -108,7 +108,7 @@ erpc_status_t MessageBuffer::Cursor::read(void *data, uint32_t length)
}
else
{
memcpy(data, m_pos, length);
(void)memcpy(data, m_pos, length);
m_pos += length;
m_remaining -= length;

Expand All @@ -130,7 +130,7 @@ erpc_status_t MessageBuffer::Cursor::write(const void *data, uint32_t length)
}
else
{
memcpy(m_pos, data, length);
(void)memcpy(m_pos, data, length);
m_pos += length;
m_remaining -= length;
m_buffer->setUsed(m_buffer->getUsed() + length);
Expand Down
6 changes: 3 additions & 3 deletions erpc_c/infra/erpc_server.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Copyright (c) 2014, Freescale Semiconductor, Inc.
* Copyright 2016-2017 NXP
* Copyright 2016-2021 NXP
* Copyright 2021 ACRIOS Systems s.r.o.
* All rights reserved.
*
Expand Down Expand Up @@ -30,7 +30,7 @@ void Server::setTransport(Transport *transport)

void Server::addService(Service *service)
{
if (!m_firstService)
if (m_firstService == NULL)
{
m_firstService = service;
}
Expand Down Expand Up @@ -90,7 +90,7 @@ erpc_status_t Server::processMessage(Codec *codec, message_type_t msgType, uint3
if (err == kErpcStatus_Success)
{
service = findServiceWithId(serviceId);
if (!service)
if (service == NULL)
{
err = kErpcStatus_InvalidArgument;
}
Expand Down
Loading

0 comments on commit 56393df

Please sign in to comment.