From 688fe79471625762bd6f3816dec9cef7f7cfb2e1 Mon Sep 17 00:00:00 2001 From: jacqueline Date: Thu, 27 Jun 2024 16:12:43 +1000 Subject: require a key press before entering the dev console this improves our ability to detect terminals that support line editing --- src/tangara/dev_console/console.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'src/tangara/dev_console/console.cpp') diff --git a/src/tangara/dev_console/console.cpp b/src/tangara/dev_console/console.cpp index cee68b49..a7f7a721 100644 --- a/src/tangara/dev_console/console.cpp +++ b/src/tangara/dev_console/console.cpp @@ -74,13 +74,29 @@ auto Console::RegisterCommonComponents() -> void { RegisterLogLevel(); } +static Console* sInstance; + +static auto prerun_cb() -> void { + if (sInstance) { + sInstance->PrerunCallback(); + } +} + +auto Console::PrerunCallback() -> void { + puts("\r\nPress any key to enter dev console.\r\n"); + setvbuf(stdin, NULL, _IONBF, 0); + fgetc(stdin); +} + auto Console::Launch() -> void { + sInstance = this; esp_console_repl_t* repl = nullptr; esp_console_repl_config_t repl_config = ESP_CONSOLE_REPL_CONFIG_DEFAULT(); repl_config.max_history_len = 16; repl_config.prompt = " →"; repl_config.max_cmdline_length = 256; repl_config.task_stack_size = 1024 * GetStackSizeKiB(); + repl_config.prerun_cb = prerun_cb; esp_console_dev_uart_config_t hw_config = ESP_CONSOLE_DEV_UART_CONFIG_DEFAULT(); -- cgit v1.2.3