@@ -230,6 +230,8 @@ Simple command handler implementation:
230
230
ARG_UNUSED(argc);
231
231
ARG_UNUSED(argv);
232
232
233
+ shell_fprintf(shell, SHELL_INFO, "Print info message\n");
234
+
233
235
shell_print(shell, "Print simple text.");
234
236
235
237
shell_warn(shell, "Print warning text.");
@@ -241,39 +243,9 @@ Simple command handler implementation:
241
243
242
244
Function :cpp:func: `shell_fprintf ` or the shell print macros:
243
245
: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.
277
249
278
250
Command help
279
251
------------
0 commit comments