From ebbc11993b1bac378da8e6f8462302c3a0bc9b3e Mon Sep 17 00:00:00 2001 From: folkert van heusden Date: Sat, 25 Mar 2023 13:21:51 +0100 Subject: [PATCH] cls/serspd commands --- ESP32/main.ino | 6 ++++++ debugger.cpp | 24 ++++++++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/ESP32/main.ino b/ESP32/main.ino index 18c0b7a..b471238 100644 --- a/ESP32/main.ino +++ b/ESP32/main.ino @@ -311,6 +311,10 @@ void start_network(console *const c) { c->put_string_lf(format("Local IP address: %s", WiFi.localIP().toString().c_str())); } +void set_tty_serial_speed(const int bps) { + Serial_RS232.begin(bps); +} + void setup() { Serial.begin(115200); @@ -340,6 +344,8 @@ void setup() { constexpr uint32_t hwSerialConfig = SERIAL_8N1; Serial_RS232.begin(115200, hwSerialConfig, 16, 17); Serial_RS232.setHwFlowCtrlMode(0); + const char clear_screen = 12; + Serial_RS232.print(clear_screen); Serial_RS232.println(F("Console enabled on TTY")); std::vector serial_ports { &Serial_RS232, &Serial }; diff --git a/debugger.cpp b/debugger.cpp index f9ace57..0d9559a 100644 --- a/debugger.cpp +++ b/debugger.cpp @@ -16,6 +16,8 @@ void configure_disk(console *const c); void configure_network(console *const c); void check_network(console *const c); void start_network(console *const c); + +void set_tty_serial_speed(const int bps); #endif // returns size of instruction (in bytes) @@ -376,9 +378,29 @@ void debugger(console *const cnsl, bus *const b, std::atomic_uint32_t *const sto else if (cmd == "startnet") { start_network(cnsl); + continue; + } + else if (parts.at(0) == "serspd") { + if (parts.size() == 2) { + int speed = std::stoi(parts.at(1), nullptr, 10); + set_tty_serial_speed(speed); + + cnsl->put_string_lf(format("Set baudrate to %d", speed)); + } + else { + cnsl->put_string_lf("serspd requires an (decimal) parameter"); + } + continue; } #endif + else if (cmd == "cls") { + const char cls[] = { 12, 0 }; + + cnsl->put_string_lf(cls); + + continue; + } else if (cmd == "turbo") { turbo = !turbo; @@ -409,11 +431,13 @@ void debugger(console *const cnsl, bus *const b, std::atomic_uint32_t *const sto cnsl->put_string_lf("setpc - set PC to value"); cnsl->put_string_lf("setmem - set memory (a=) to value (v=), both in octal, one byte"); cnsl->put_string_lf("toggle - set switch (s=, 0...15 (decimal)) of the front panel to state (t=, 0 or 1)"); + cnsl->put_string_lf("cls - clear screen"); #if defined(ESP32) cnsl->put_string_lf("cfgnet - configure network (e.g. WiFi)"); cnsl->put_string_lf("startnet - start network"); cnsl->put_string_lf("chknet - check network status"); cnsl->put_string_lf("cfgdisk - configure disk"); + cnsl->put_string_lf("serspd - set serial speed in bps (8N1 are default)"); #endif continue;