require a key press before entering the dev console

this improves our ability to detect terminals that support line editing
custom
jacqueline 10 months ago
parent 1036f1b00e
commit 688fe79471
  1. 16
      src/tangara/dev_console/console.cpp
  2. 1
      src/tangara/dev_console/console.hpp
  3. 8
      src/tangara/system_fsm/booting.cpp
  4. 11
      test/main/main.cpp

@ -74,13 +74,29 @@ auto Console::RegisterCommonComponents() -> void {
RegisterLogLevel(); 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 { auto Console::Launch() -> void {
sInstance = this;
esp_console_repl_t* repl = nullptr; esp_console_repl_t* repl = nullptr;
esp_console_repl_config_t repl_config = ESP_CONSOLE_REPL_CONFIG_DEFAULT(); esp_console_repl_config_t repl_config = ESP_CONSOLE_REPL_CONFIG_DEFAULT();
repl_config.max_history_len = 16; repl_config.max_history_len = 16;
repl_config.prompt = ""; repl_config.prompt = "";
repl_config.max_cmdline_length = 256; repl_config.max_cmdline_length = 256;
repl_config.task_stack_size = 1024 * GetStackSizeKiB(); 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_t hw_config =
ESP_CONSOLE_DEV_UART_CONFIG_DEFAULT(); ESP_CONSOLE_DEV_UART_CONFIG_DEFAULT();

@ -16,6 +16,7 @@ class Console {
virtual ~Console(); virtual ~Console();
auto Launch() -> void; auto Launch() -> void;
virtual auto PrerunCallback() -> void;
protected: protected:
virtual auto GetStackSizeKiB() -> uint16_t { return 8; } virtual auto GetStackSizeKiB() -> uint16_t { return 8; }

@ -115,9 +115,11 @@ auto Booting::entry() -> void {
auto Booting::exit() -> void { auto Booting::exit() -> void {
// TODO(jacqueline): Gate this on something. Debug flag? Flashing mode? // TODO(jacqueline): Gate this on something. Debug flag? Flashing mode?
sAppConsole = new console::AppConsole(); sServices->bg_worker().Dispatch<void>([&] {
sAppConsole->sServices = sServices; sAppConsole = new console::AppConsole();
sAppConsole->Launch(); sAppConsole->sServices = sServices;
sAppConsole->Launch();
});
TimerHandle_t timer = xTimerCreate("INTERRUPTS", kInterruptCheckPeriod, true, TimerHandle_t timer = xTimerCreate("INTERRUPTS", kInterruptCheckPeriod, true,
NULL, check_interrupts_cb); NULL, check_interrupts_cb);

@ -5,9 +5,13 @@
*/ */
#include <stdio.h> #include <stdio.h>
#include <sys/fcntl.h>
#include <sys/unistd.h>
#include <cstdint> #include <cstdint>
#include "freertos/FreeRTOS.h"
#include "catch_runner.hpp" #include "catch_runner.hpp"
#include "esp_console.h" #include "esp_console.h"
#include "esp_log.h" #include "esp_log.h"
@ -27,6 +31,13 @@ void RegisterCatch2() {
namespace console { namespace console {
class TestConsole : public Console { class TestConsole : public Console {
public:
virtual auto PrerunCallback() -> void {
char* arg = "catch";
exec_catch2(1, &arg);
Console::PrerunCallback();
}
protected: protected:
virtual auto RegisterExtraComponents() -> void { RegisterCatch2(); } virtual auto RegisterExtraComponents() -> void { RegisterCatch2(); }
virtual auto GetStackSizeKiB() -> uint16_t { virtual auto GetStackSizeKiB() -> uint16_t {

Loading…
Cancel
Save