Skip to content

Commit 4c3bcba

Browse files
Jakub Rzeszutkocarlescufi
authored andcommitted
shell: documentation update
Updated documantation in regards to new shell printing strategy. Signed-off-by: Jakub Rzeszutko <[email protected]>
1 parent ce6be86 commit 4c3bcba

File tree

2 files changed

+6
-33
lines changed

2 files changed

+6
-33
lines changed

doc/subsystems/shell/shell.rst

Lines changed: 5 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,8 @@ Simple command handler implementation:
230230
ARG_UNUSED(argc);
231231
ARG_UNUSED(argv);
232232
233+
shell_fprintf(shell, SHELL_INFO, "Print info message\n");
234+
233235
shell_print(shell, "Print simple text.");
234236
235237
shell_warn(shell, "Print warning text.");
@@ -241,39 +243,9 @@ Simple command handler implementation:
241243
242244
Function :cpp:func:`shell_fprintf` or the shell print macros:
243245
:c:macro:`shell_print`, :c:macro:`shell_info`, :c:macro:`shell_warn` and
244-
:c:macro:`shell_error` can only be used from the command handler, or if the
245-
command context is forced to stay in the foreground by calling
246-
:cpp:func:`shell_command_enter` from within the command handler. In this latter
247-
case, the shell stops reading input and writing to the output (except for the
248-
logs), allowing a user to print from any thread context. Function
249-
:cpp:func:`shell_command_exit` or entering a :kbd:`CTRL+C` terminates a
250-
'foreground' command.
251-
252-
Here is an example foreground command implementation:
253-
254-
.. code-block:: c
255-
256-
static int cmd_handler(const struct shell *shell, size_t argc,
257-
char **argv)
258-
{
259-
ARG_UNUSED(argc);
260-
ARG_UNUSED(argv);
261-
262-
shell_command_enter(shell);
263-
264-
foo_shell = shell;
265-
foo_signal_thread(); /* Swtich context */
266-
267-
return 0;
268-
}
269-
270-
static void foo_thread_context(void)
271-
{
272-
shell_print(foo_shell, "Lorem ipsum");
273-
274-
/* Terminate foreground command. */
275-
shell_command_exit(foo_shell);
276-
}
246+
:c:macro:`shell_error` can be used from the command handler or from threads,
247+
but not from an interrupt context. Instead, interrupt handlers should use
248+
:ref:`logger` for printing.
277249

278250
Command help
279251
------------

subsys/shell/shell.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1212,6 +1212,7 @@ void shell_thread(void *shell_handle, void *arg_log_backend,
12121212
}
12131213

12141214
while (true) {
1215+
/* waiting for all signals except SHELL_SIGNAL_TXDONE */
12151216
err = k_poll(shell->ctx->events, SHELL_SIGNAL_TXDONE,
12161217
K_FOREVER);
12171218

0 commit comments

Comments
 (0)