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 fe25948
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
11 changes: 8 additions & 3 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,8 @@ 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("sidewalk workq usage (%d/%d) ( after get )",
k_msgq_num_used_get(&sidewalk_thread_msgq),
CONFIG_SIDEWALK_THREAD_QUEUE_SIZE);
#endif
if (!err) {
Expand All @@ -43,6 +46,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 Down Expand Up @@ -76,8 +81,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),
CONFIG_SIDEWALK_THREAD_QUEUE_SIZE);
LOG_INF("sidewalk workq usage (%d/%d) (after put)",
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,
ctx, result);
Expand Down
9 changes: 5 additions & 4 deletions samples/sid_end_device/src/sidewalk_events.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,11 @@ void sidewalk_event_process(sidewalk_ctx_t *sid, void *ctx)
LOG_INF("sidewalk need to be started first.");
return;
}
sid_error_t e = sid_process(sid->handle);
if (e) {
LOG_ERR("sid process err %d (%s)", (int)e, SID_ERROR_T_STR(e));
}
// TODO: sid_process is called in a loop in sidewalk thread for testing
// sid_error_t e = sid_process(sid->handle);
// if (e) {
// LOG_ERR("sid process err %d (%s)", (int)e, SID_ERROR_T_STR(e));
// }
}

void sidewalk_event_platform_init(sidewalk_ctx_t *sid, void *ctx)
Expand Down

0 comments on commit fe25948

Please sign in to comment.