Skip to content

Commit

Permalink
test: check if sid_process is blocking the queue
Browse files Browse the repository at this point in the history
check if calling sid_process in a loop will solve the issue

Signed-off-by: Robert Gałat <[email protected]>
  • Loading branch information
RobertGalatNordic committed Feb 10, 2025
1 parent 1b0630d commit be2c24b
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions samples/sid_end_device/src/sidewalk.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
*
* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
*/
#include <sid_api.h>
#include <sid_error.h>
#include <sidewalk.h>

#include <zephyr/kernel.h>
Expand Down Expand Up @@ -30,7 +32,9 @@ static void sid_thread_entry(void *context, void *unused, void *unused2)
while (1) {
int err = k_msgq_get(&sidewalk_thread_msgq, &event, K_FOREVER);
#if CONFIG_SIDEWALK_TRACE_SIDEWALK_QUEUE
LOG_INF("sidewalk workq usage (%d/%d)", k_msgq_num_used_get(&sidewalk_thread_msgq),
LOG_INF("event handler get = %p, sidewalk workq usage (%d/%d) ( after get )",
((sidewalk_ctx_event_t *)event)->handler,
k_msgq_num_used_get(&sidewalk_thread_msgq),
CONFIG_SIDEWALK_THREAD_QUEUE_SIZE);
#endif
if (!err) {
Expand All @@ -43,6 +47,8 @@ static void sid_thread_entry(void *context, void *unused, void *unused2)
} else {
LOG_ERR("Sidewalk msgq err %d", err);
}
sid_error_t _ignore = sid_process(sid->handle);
ARG_UNUSED(_ignore);
}

LOG_ERR("Sidewalk thread ends. You should never see this message.");
Expand All @@ -59,6 +65,9 @@ void sidewalk_start(sidewalk_ctx_t *context)

int sidewalk_event_send(event_handler_t event, void *ctx, ctx_free free)
{
if (event == sidewalk_event_process) {
return 0;
}
sidewalk_ctx_event_t ctx_event = {
.handler = event,
.ctx = ctx,
Expand All @@ -76,7 +85,8 @@ int sidewalk_event_send(event_handler_t event, void *ctx, ctx_free free)
#endif /* CONFIG_SIDEWALK_THREAD_QUEUE_TIMEOUT_VALUE > 0 */
result = k_msgq_put(&sidewalk_thread_msgq, (void *)&ctx_event, timeout);
#if CONFIG_SIDEWALK_TRACE_SIDEWALK_QUEUE
LOG_INF("sidewalk workq usage (%d/%d)", k_msgq_num_used_get(&sidewalk_thread_msgq),
LOG_INF("event handler send = %p, sidewalk workq usage (%d/%d) (after put)",
(event_handler_t *)event, k_msgq_num_used_get(&sidewalk_thread_msgq),
CONFIG_SIDEWALK_THREAD_QUEUE_SIZE);
#endif
LOG_DBG("sidewalk_event_send event = %p, context = %p, k_msgq_put result %d", (void *)event,
Expand Down

0 comments on commit be2c24b

Please sign in to comment.