Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

client manager: added user context to error handler (#424) #425

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion erpc_c/infra/erpc_client_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,6 @@ void ClientManager::callErrorHandler(erpc_status_t err, uint32_t functionID)
{
if (m_errorHandler != NULL)
{
m_errorHandler(err, functionID);
m_errorHandler(err, functionID, m_errorHandlerContext);
}
}
15 changes: 11 additions & 4 deletions erpc_c/infra/erpc_client_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,9 @@ extern "C" {
#include "erpc_common.h"
#endif

typedef void (*client_error_handler_t)(erpc_status_t err,
uint32_t functionID); /*!< eRPC error handler function type. */
typedef void (*client_error_handler_t)(erpc_status_t err, /*!< eRPC error code. */
uint32_t functionID, /*!< eRPC error handler function type. */
void *context); /*!< User supplied context. */

//! @brief Opaque client object type.
typedef struct ClientType *erpc_client_t;
Expand Down Expand Up @@ -62,7 +63,7 @@ class ClientManager : public ClientServerCommon
* This function initializes object attributes.
*/
ClientManager(void) :
ClientServerCommon(), m_sequence(0), m_errorHandler(NULL)
ClientServerCommon(), m_sequence(0), m_errorHandler(NULL), m_errorHandlerContext(NULL)
#if ERPC_NESTED_CALLS
,
m_server(NULL), m_serverThreadId(NULL)
Expand Down Expand Up @@ -100,8 +101,13 @@ class ClientManager : public ClientServerCommon
* @brief This function sets error handler function for infrastructure errors.
*
* @param[in] error_handler Pointer to error handler function.
* @param[in] error_handler_context Pointer to error handler user context.
*/
void setErrorHandler(client_error_handler_t error_handler) { m_errorHandler = error_handler; }
void setErrorHandler(client_error_handler_t error_handler, void *error_handler_context)
{
m_errorHandler = error_handler;
m_errorHandlerContext = error_handler_context;
}

/*!
* @brief This function calls error handler callback function with given status.
Expand Down Expand Up @@ -132,6 +138,7 @@ class ClientManager : public ClientServerCommon
protected:
uint32_t m_sequence; //!< Sequence number.
client_error_handler_t m_errorHandler; //!< Pointer to function error handler.
void *m_errorHandlerContext; //!< Pointer to a user supplied context.
#if ERPC_NESTED_CALLS
Server *m_server; //!< Server used for nested calls.
Thread::thread_id_t m_serverThreadId; //!< Thread in which server run function is called.
Expand Down
2 changes: 1 addition & 1 deletion erpc_c/setup/erpc_arbitrated_client_setup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ void erpc_arbitrated_client_set_error_handler(erpc_client_t client, client_error

ArbitratedClientManager *clientManager = reinterpret_cast<ArbitratedClientManager *>(client);

clientManager->setErrorHandler(error_handler);
clientManager->setErrorHandler(error_handler, NULL);
}

void erpc_arbitrated_client_set_crc(erpc_client_t client, uint32_t crcStart)
Expand Down
2 changes: 1 addition & 1 deletion erpc_c/setup/erpc_client_setup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ void erpc_client_set_error_handler(erpc_client_t client, client_error_handler_t

ClientManager *clientManager = reinterpret_cast<ClientManager *>(client);

clientManager->setErrorHandler(error_handler);
clientManager->setErrorHandler(error_handler, NULL);
}

void erpc_client_set_crc(erpc_client_t client, uint32_t crcStart)
Expand Down