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

nrf_rpc: fix error handling #1548

Merged
merged 1 commit into from
Oct 31, 2024
Merged
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
12 changes: 9 additions & 3 deletions nrf_rpc/nrf_rpc.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ struct internal_pool_data {
static struct nrf_rpc_cmd_ctx cmd_ctx_pool[CONFIG_NRF_RPC_CMD_CTX_POOL_SIZE];

static struct nrf_rpc_os_event groups_init_event;
static struct nrf_rpc_os_event error_event;
Damian-Nordic marked this conversation as resolved.
Show resolved Hide resolved

/* Number of groups */
static uint8_t group_count;
Expand Down Expand Up @@ -362,16 +363,16 @@ static void internal_tx_handler(void)
{
struct internal_pool_data copy = internal_data;

nrf_rpc_os_event_set(&copy.group->data->decode_done_event);

if (copy.type == NRF_RPC_INITIALIZATION) {
nrf_rpc_os_event_set(&copy.group->data->decode_done_event);
if (group_init_send(copy.group)) {
NRF_RPC_ERR("Failed to send group init packet for group id: %d strid: %s",
copy.group->data->src_group_id, copy.group->strid);
}
}

if (copy.type == NRF_RPC_ERROR) {
nrf_rpc_os_event_set(&error_event);
nrf_rpc_err(copy.err, NRF_RPC_ERR_SRC_RECV, copy.group, copy.hdr_id, copy.hdr_type);
}
}
Expand Down Expand Up @@ -807,7 +808,7 @@ static void receive_handler(const struct nrf_rpc_tr *transport, const uint8_t *p
internal_data.hdr_id = hdr.id;
internal_data.hdr_type = hdr.type;
nrf_rpc_os_thread_pool_send((const uint8_t *)&internal_data, sizeof(internal_data));
nrf_rpc_os_event_wait(&group->data->decode_done_event, NRF_RPC_OS_WAIT_FOREVER);
nrf_rpc_os_event_wait(&error_event, NRF_RPC_OS_WAIT_FOREVER);
}
}

Expand Down Expand Up @@ -1082,6 +1083,11 @@ int nrf_rpc_init(nrf_rpc_err_handler_t err_handler)
return err;
}

err = nrf_rpc_os_event_init(&error_event);
if (err < 0) {
return err;
}

for (i = 0; i < CONFIG_NRF_RPC_CMD_CTX_POOL_SIZE; i++) {
cmd_ctx_pool[i].id = i;
err = nrf_rpc_os_msg_init(&cmd_ctx_pool[i].recv_msg);
Expand Down
Loading