summaryrefslogtreecommitdiff
path: root/src/tangara/dev_console/console.cpp
diff options
context:
space:
mode:
authorjacqueline <me@jacqueline.id.au>2024-06-27 16:12:43 +1000
committerjacqueline <me@jacqueline.id.au>2024-06-27 16:12:43 +1000
commit688fe79471625762bd6f3816dec9cef7f7cfb2e1 (patch)
tree99404dea80650d805e094d3da26641bda3058c6d /src/tangara/dev_console/console.cpp
parent1036f1b00efe2bbd2467cbfa3a4a97ab7f56591e (diff)
downloadtangara-fw-688fe79471625762bd6f3816dec9cef7f7cfb2e1.tar.gz
require a key press before entering the dev console
this improves our ability to detect terminals that support line editing
Diffstat (limited to 'src/tangara/dev_console/console.cpp')
-rw-r--r--src/tangara/dev_console/console.cpp16
1 files changed, 16 insertions, 0 deletions
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();