Skip to content

Commit 2f93ce6

Browse files
jakub-uCnashif
authored andcommitted
shell: add Kconfig option for configurable autoflush behavior
Introduced a new Kconfig option `SHELL_PRINTF_AUTOFLUSH` to allow configuring the autoflush behavior of shell printing functions. Updated `Z_SHELL_FPRINTF_DEFINE` to use the `CONFIG_SHELL_PRINTF_AUTOFLUSH` setting instead of hardcoding the autoflush behavior to `true`. Signed-off-by: Jakub Rzeszutko <[email protected]> (cherry picked from commit 8991b95)
1 parent 4ef146d commit 2f93ce6

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

include/zephyr/shell/shell.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -936,7 +936,8 @@ extern void z_shell_print_stream(const void *user_ctx, const char *data,
936936
Z_SHELL_HISTORY_DEFINE(_name##_history, CONFIG_SHELL_HISTORY_BUFFER); \
937937
Z_SHELL_FPRINTF_DEFINE(_name##_fprintf, &_name, _name##_out_buffer, \
938938
CONFIG_SHELL_PRINTF_BUFF_SIZE, \
939-
true, z_shell_print_stream); \
939+
IS_ENABLED(CONFIG_SHELL_PRINTF_AUTOFLUSH), \
940+
z_shell_print_stream); \
940941
LOG_INSTANCE_REGISTER(shell, _name, CONFIG_SHELL_LOG_LEVEL); \
941942
Z_SHELL_STATS_DEFINE(_name); \
942943
static K_KERNEL_STACK_DEFINE(_name##_stack, CONFIG_SHELL_STACK_SIZE); \

subsys/shell/Kconfig

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,13 @@ config SHELL_PRINTF_BUFF_SIZE
8989
It is working like stdio buffering in Linux systems
9090
to limit number of peripheral access calls.
9191

92+
config SHELL_PRINTF_AUTOFLUSH
93+
bool "Indicate if the buffer should be automatically flushed"
94+
default y
95+
help
96+
Specify whether the shell's printing functions should automatically
97+
flush the printf buffer.
98+
9299
config SHELL_DEFAULT_TERMINAL_WIDTH
93100
int "Default terminal width"
94101
default 80

0 commit comments

Comments
 (0)