From 98a1a1510cac1e37930bc43f30ef02502a8861ea Mon Sep 17 00:00:00 2001 From: Jakub Rzeszutko Date: Tue, 21 Jan 2025 12:33:06 +0100 Subject: [PATCH] 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 (cherry picked from commit 8991b954bc8c1941ed52a075ce354e23545e61bc) --- include/zephyr/shell/shell.h | 2 +- subsys/shell/Kconfig | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/include/zephyr/shell/shell.h b/include/zephyr/shell/shell.h index e2a40b85328..c175a149278 100644 --- a/include/zephyr/shell/shell.h +++ b/include/zephyr/shell/shell.h @@ -930,7 +930,7 @@ extern void z_shell_print_stream(const void *user_ctx, const char *data, static struct shell_ctx UTIL_CAT(_name, _ctx); \ Z_SHELL_HISTORY_DEFINE(_name##_history, CONFIG_SHELL_HISTORY_BUFFER); \ Z_SHELL_FPRINTF_DEFINE(_name##_fprintf, &_name, _out_buf, CONFIG_SHELL_PRINTF_BUFF_SIZE, \ - true, z_shell_print_stream); \ + IS_ENABLED(CONFIG_SHELL_PRINTF_AUTOFLUSH), z_shell_print_stream); \ LOG_INSTANCE_REGISTER(shell, _name, CONFIG_SHELL_LOG_LEVEL); \ Z_SHELL_STATS_DEFINE(_name); \ static K_KERNEL_STACK_DEFINE(_name##_stack, CONFIG_SHELL_STACK_SIZE); \ diff --git a/subsys/shell/Kconfig b/subsys/shell/Kconfig index 696d070a7e4..9d1b807c8ba 100644 --- a/subsys/shell/Kconfig +++ b/subsys/shell/Kconfig @@ -89,6 +89,13 @@ config SHELL_PRINTF_BUFF_SIZE It is working like stdio buffering in Linux systems to limit number of peripheral access calls. +config SHELL_PRINTF_AUTOFLUSH + bool "Indicate if the buffer should be automatically flushed" + default y + help + Specify whether the shell's printing functions should automatically + flush the printf buffer. + config SHELL_DEFAULT_TERMINAL_WIDTH int "Default terminal width" range 1 $(UINT16_MAX)