Skip to content

Commit

Permalink
shell: Move signals initialization from thread to init
Browse files Browse the repository at this point in the history
By moving signals initialization to shell instance init function,
shell instance is ready to receive RX signals from backend before
thread is ready to handle them.

Signed-off-by: Krzysztof Chruscinski <[email protected]>
  • Loading branch information
nordic-krch authored and carlescufi committed May 13, 2019
1 parent ca4a078 commit 3b99b20
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions subsys/shell/shell.c
Original file line number Diff line number Diff line change
Expand Up @@ -1102,6 +1102,14 @@ static int instance_init(const struct shell *shell, const void *p_config,

k_mutex_init(&shell->ctx->wr_mtx);

for (int i = 0; i < SHELL_SIGNALS; i++) {
k_poll_signal_init(&shell->ctx->signals[i]);
k_poll_event_init(&shell->ctx->events[i],
K_POLL_TYPE_SIGNAL,
K_POLL_MODE_NOTIFY_ONLY,
&shell->ctx->signals[i]);
}

if (IS_ENABLED(CONFIG_SHELL_STATS)) {
shell->stats->log_lost_cnt = 0;
}
Expand Down Expand Up @@ -1179,14 +1187,6 @@ void shell_thread(void *shell_handle, void *arg_log_backend,
u32_t log_level = (u32_t)arg_log_level;
int err;

for (int i = 0; i < SHELL_SIGNALS; i++) {
k_poll_signal_init(&shell->ctx->signals[i]);
k_poll_event_init(&shell->ctx->events[i],
K_POLL_TYPE_SIGNAL,
K_POLL_MODE_NOTIFY_ONLY,
&shell->ctx->signals[i]);
}

err = shell->iface->api->enable(shell->iface, false);
if (err != 0) {
return;
Expand Down

0 comments on commit 3b99b20

Please sign in to comment.