summaryrefslogtreecommitdiff
path: root/src/tangara
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
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')
-rw-r--r--src/tangara/dev_console/console.cpp16
-rw-r--r--src/tangara/dev_console/console.hpp1
-rw-r--r--src/tangara/system_fsm/booting.cpp8
3 files changed, 22 insertions, 3 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();
diff --git a/src/tangara/dev_console/console.hpp b/src/tangara/dev_console/console.hpp
index fedf3632..f29723e9 100644
--- a/src/tangara/dev_console/console.hpp
+++ b/src/tangara/dev_console/console.hpp
@@ -16,6 +16,7 @@ class Console {
virtual ~Console();
auto Launch() -> void;
+ virtual auto PrerunCallback() -> void;
protected:
virtual auto GetStackSizeKiB() -> uint16_t { return 8; }
diff --git a/src/tangara/system_fsm/booting.cpp b/src/tangara/system_fsm/booting.cpp
index feba0dc0..9d505f81 100644
--- a/src/tangara/system_fsm/booting.cpp
+++ b/src/tangara/system_fsm/booting.cpp
@@ -115,9 +115,11 @@ auto Booting::entry() -> void {
auto Booting::exit() -> void {
// TODO(jacqueline): Gate this on something. Debug flag? Flashing mode?
- sAppConsole = new console::AppConsole();
- sAppConsole->sServices = sServices;
- sAppConsole->Launch();
+ sServices->bg_worker().Dispatch<void>([&] {
+ sAppConsole = new console::AppConsole();
+ sAppConsole->sServices = sServices;
+ sAppConsole->Launch();
+ });
TimerHandle_t timer = xTimerCreate("INTERRUPTS", kInterruptCheckPeriod, true,
NULL, check_interrupts_cb);