Skip to content

Commit

Permalink
eRPC updates 12/2019
Browse files Browse the repository at this point in the history
-- improved the test_callbacks logic to be more understandable and to allow requested callback execution on the server side
-- transportArbitrator::prepareClientReceive modified to avoid incorrect return value type
-- the ClientManager and the ArbitratedClientManager updated to avoid performing client requests when the previous serialization phase fails
-- generate the shim code for destroy of statically allocated services
-- documentation update for v1.7.3
  • Loading branch information
MichalPrincNXP committed Dec 17, 2019
1 parent 74b2811 commit f748151
Show file tree
Hide file tree
Showing 55 changed files with 389 additions and 328 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Client side usage:
void example_client(void) {
// Initialize client running over UART.
erpc_client_init(
erpc_transport_cmsis_uart_init(UART0_NonBlocking_Driver);
erpc_transport_cmsis_uart_init(Driver_USART0);
// Now we can call the remote function to turn on the green LED.
set_led(kGreen, true);
Expand All @@ -43,7 +43,7 @@ void set_led(LEDName whichLed, bool onOrOff) {
void example_server(void) {
// Initialize server running over UART.
erpc_server_init(
erpc_transport_uart_init(UART0_NonBlocking_Driver);
erpc_transport_cmsis_uart_init(Driver_USART0);
// Add the IO service.
erpc_add_service_to_server(create_IO_service());
Expand Down Expand Up @@ -71,7 +71,7 @@ eRPC is available with an unrestrictive BSD 3-clause license. See the LICENSE fi

## Documentation

[Documentation](https://github.com/EmbeddedRPC/erpc/wiki) is in the `wiki` section. Commit sha in wiki repository: 7199a9c00fef4b952a6b05a8e3b0257f788e4eeb.
[Documentation](https://github.com/EmbeddedRPC/erpc/wiki) is in the `wiki` section. Commit sha in wiki repository: 431cba8.

[Example IDL](examples/README.md) is available in the `examples/` folder.

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.7.2"
PROJECT_NUMBER = "Rev. 1.7.3"

# 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.7.2"
PROJECT_NUMBER = "Rev. 1.7.3"

# 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
6 changes: 3 additions & 3 deletions erpc_c/config/erpc_config.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Copyright (c) 2016, Freescale Semiconductor, Inc.
* Copyright 2016-2018 NXP
* Copyright 2016-2019 NXP
* All rights reserved.
*
*
Expand Down Expand Up @@ -94,7 +94,7 @@

//! @def ERPC_MESSAGE_LOGGING
//!
//! Enable eRPC message logging code through the eRPC. Take look into "message_logging.h". Can be used for base printing
//! Enable eRPC message logging code through the eRPC. Take look into "erpc_message_loggers.h". Can be used for base printing
//! messages, or sending data to another system for data analysis. Default set to ERPC_MESSAGE_LOGGING_DISABLED.
//!
//! Uncomment for using logging feature.
Expand All @@ -112,7 +112,7 @@
//! is part of the project, otherwise the ERPC_TRANSPORT_MU_USE_MCMGR_DISABLED option is used. This settings can be
//! overwritten from the erpc_config.h by uncommenting the ERPC_TRANSPORT_MU_USE_MCMGR macro definition. Do not forget
//! to add the MCMGR library into your project when ERPC_TRANSPORT_MU_USE_MCMGR_ENABLED option is used! See the
//! mu_transport.h for additional MU settings.
//! erpc_mu_transport.h for additional MU settings.
//#define ERPC_TRANSPORT_MU_USE_MCMGR ERPC_TRANSPORT_MU_USE_MCMGR_DISABLED
//@}

Expand Down
25 changes: 16 additions & 9 deletions erpc_c/infra/erpc_arbitrated_client_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ void ArbitratedClientManager::setArbitrator(TransportArbitrator *arbitrator)
m_transport = arbitrator;
}

erpc_status_t ArbitratedClientManager::performClientRequest(RequestContext &request)
void ArbitratedClientManager::performClientRequest(RequestContext &request)
{
assert(m_arbitrator && "arbitrator not set");

Expand All @@ -42,13 +42,15 @@ erpc_status_t ArbitratedClientManager::performClientRequest(RequestContext &requ
#if ERPC_NESTED_CALLS_DETECTION
if (nestingDetection)
{
return kErpcStatus_NestedCallFailure;
request.getCodec()->updateStatus(kErpcStatus_NestedCallFailure);
return;
}
#endif
token = m_arbitrator->prepareClientReceive(request);
if (!token)
{
return kErpcStatus_Fail;
request.getCodec()->updateStatus(kErpcStatus_Fail);
return;
}
}

Expand All @@ -58,15 +60,17 @@ erpc_status_t ArbitratedClientManager::performClientRequest(RequestContext &requ
err = logMessage(request.getCodec()->getBuffer());
if (err)
{
return err;
request.getCodec()->updateStatus(err);
return;
}
#endif

// Send the request.
err = m_arbitrator->send(request.getCodec()->getBuffer());
if (err)
{
return err;
request.getCodec()->updateStatus(err);
return;
}

if (!request.isOneway())
Expand All @@ -75,24 +79,27 @@ erpc_status_t ArbitratedClientManager::performClientRequest(RequestContext &requ
err = m_arbitrator->clientReceive(token);
if (err)
{
return err;
request.getCodec()->updateStatus(err);
return;
}

#if ERPC_MESSAGE_LOGGING
err = logMessage(request.getCodec()->getBuffer());
if (err)
{
return err;
request.getCodec()->updateStatus(err);
return;
}
#endif

// Check the reply.
err = verifyReply(request);
if (err)
{
return err;
request.getCodec()->updateStatus(err);
return;
}
}

return kErpcStatus_Success;
return;
}
2 changes: 1 addition & 1 deletion erpc_c/infra/erpc_arbitrated_client_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class ArbitratedClientManager : public ClientManager
*
* @param[in] request Request context to perform.
*/
virtual erpc_status_t performClientRequest(RequestContext &request);
virtual void performClientRequest(RequestContext &request);

//! @brief This method is not used with this class.
void setTransport(Transport *transport) {}
Expand Down
50 changes: 33 additions & 17 deletions erpc_c/infra/erpc_client_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,15 @@ RequestContext ClientManager::createRequest(bool isOneway)
return RequestContext(++m_sequence, codec, isOneway);
}

erpc_status_t ClientManager::performRequest(RequestContext &request)
void ClientManager::performRequest(RequestContext &request)
{
// Check the codec status
if (kErpcStatus_Success != (request.getCodec()->getStatus()))
{
// Do not perform the request
return;
}

#if ERPC_NESTED_CALLS
assert(m_serverThreadId && "server thread id was not set");
if (Thread::getCurrentThreadId() == m_serverThreadId)
Expand All @@ -47,12 +54,13 @@ erpc_status_t ClientManager::performRequest(RequestContext &request)
return performClientRequest(request);
}

erpc_status_t ClientManager::performClientRequest(RequestContext &request)
void ClientManager::performClientRequest(RequestContext &request)
{
#if ERPC_NESTED_CALLS_DETECTION
if (!request.isOneway() && nestingDetection)
{
return kErpcStatus_NestedCallFailure;
request.getCodec()->updateStatus(kErpcStatus_NestedCallFailure);
return;
}
#endif

Expand All @@ -62,15 +70,17 @@ erpc_status_t ClientManager::performClientRequest(RequestContext &request)
err = logMessage(request.getCodec()->getBuffer());
if (err)
{
return err;
request.getCodec()->updateStatus(err);
return;
}
#endif

// Send invocation request to server.
err = m_transport->send(request.getCodec()->getBuffer());
if (err)
{
return err;
request.getCodec()->updateStatus(err);
return;
}

// If the request is oneway, then there is nothing more to do.
Expand All @@ -80,30 +90,33 @@ erpc_status_t ClientManager::performClientRequest(RequestContext &request)
err = m_transport->receive(request.getCodec()->getBuffer());
if (err)
{
return err;
request.getCodec()->updateStatus(err);
return;
}

#if ERPC_MESSAGE_LOGGING
err = logMessage(request.getCodec()->getBuffer());
if (err)
{
return err;
request.getCodec()->updateStatus(err);
return;
}
#endif

// Check the reply.
err = verifyReply(request);
if (err)
{
return err;
request.getCodec()->updateStatus(err);
return;
}
}

return kErpcStatus_Success;
return;
}

#if ERPC_NESTED_CALLS
erpc_status_t ClientManager::performNestedClientRequest(RequestContext &request)
void ClientManager::performNestedClientRequest(RequestContext &request)
{
assert(m_transport && "transport/arbitrator not set");

Expand All @@ -113,15 +126,17 @@ erpc_status_t ClientManager::performNestedClientRequest(RequestContext &request)
err = logMessage(request.getCodec()->getBuffer());
if (err)
{
return err;
request.getCodec()->updateStatus(err);
return;
}
#endif

// Send invocation request to server.
err = m_transport->send(request.getCodec()->getBuffer());
if (err)
{
return err;
request.getCodec()->updateStatus(err);
return;
}

// If the request is oneway, then there is nothing more to do.
Expand All @@ -132,26 +147,27 @@ erpc_status_t ClientManager::performNestedClientRequest(RequestContext &request)
err = m_server->run(request);
if (err)
{
return err;
request.getCodec()->updateStatus(err);
return;
}

#if ERPC_MESSAGE_LOGGING
err = logMessage(request.getCodec()->getBuffer());
if (err)
{
return err;
request.getCodec()->updateStatus(err);
return;
}
#endif

// Check the reply.
err = verifyReply(request);
if (err)
{
return err;
request.getCodec()->updateStatus(err);
return;
}
}

return kErpcStatus_Success;
}
#endif

Expand Down
6 changes: 3 additions & 3 deletions erpc_c/infra/erpc_client_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ class ClientManager
*
* @param[in] request Request context to perform.
*/
virtual erpc_status_t performRequest(RequestContext &request);
virtual void performRequest(RequestContext &request);

/*!
* @brief This function releases request context.
Expand Down Expand Up @@ -180,7 +180,7 @@ class ClientManager
*
* @param[in] request Request context to perform.
*/
virtual erpc_status_t performClientRequest(RequestContext &request);
virtual void performClientRequest(RequestContext &request);

#if ERPC_NESTED_CALLS
/*!
Expand All @@ -190,7 +190,7 @@ class ClientManager
*
* @param[in] request Request context to perform.
*/
virtual erpc_status_t performNestedClientRequest(RequestContext &request);
virtual void performNestedClientRequest(RequestContext &request);
#endif

//! @brief Validate that an incoming message is a reply.
Expand Down
20 changes: 20 additions & 0 deletions erpc_c/infra/erpc_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,26 @@ void Server::addService(Service *service)
link->setNext(service);
}

void Server::removeService(Service *service)
{
Service *link = m_firstService;

if (link == service)
{
m_firstService = link->getNext();
return;
}
while (link != NULL)
{
if (link->getNext() == service)
{
link->setNext(link->getNext()->getNext());
return;
}
link = link->getNext();
}
}

erpc_status_t Server::readHeadOfMessage(Codec *codec, message_type_t &msgType, uint32_t &serviceId, uint32_t &methodId,
uint32_t &sequence)
{
Expand Down
7 changes: 7 additions & 0 deletions erpc_c/infra/erpc_server.h
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,13 @@ class Server
*/
void addService(Service *service);

/*!
* @brief Remove service.
*
* @param[in] service Service to remove.
*/
void removeService(Service *service);

/*!
* @brief This function runs the server.
*/
Expand Down
10 changes: 0 additions & 10 deletions erpc_c/infra/erpc_simple_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,6 @@ using namespace erpc;
// Code
////////////////////////////////////////////////////////////////////////////////

SimpleServer::~SimpleServer(void)
{
while (m_firstService != NULL)
{
Service *firstService = m_firstService;
m_firstService = m_firstService->getNext();
delete firstService;
}
}

void SimpleServer::disposeBufferAndCodec(Codec *codec)
{
if (codec)
Expand Down
Loading

0 comments on commit f748151

Please sign in to comment.