From 04d9c89b3b3ecc131212777d0d90ee2ee1fa5503 Mon Sep 17 00:00:00 2001 From: folkert van heusden Date: Thu, 9 Jun 2022 21:05:51 +0200 Subject: [PATCH] log lines of tty-output in debug-log --- console.cpp | 14 +++++++++++++- console.h | 2 ++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/console.cpp b/console.cpp index 72b7fd2..f055c50 100644 --- a/console.cpp +++ b/console.cpp @@ -163,8 +163,15 @@ void console::put_char(const char c) } else if (c == 13) tx = 0; - else if (c == 10) + else if (c == 10) { + if (debug_buffer.empty() == false) { + D(fprintf(stderr, "TTY: %s\n", debug_buffer.c_str());) + + debug_buffer.clear(); + } + ty++; + } else if (c == 8) { // backspace if (tx > 0) tx--; @@ -177,6 +184,9 @@ void console::put_char(const char c) ty++; } + + if (debug_buffer.size() < 4096) + debug_buffer += c; } if (ty == t_height) { @@ -208,6 +218,8 @@ void console::operator()() bool running_flag = *get_running_flag(); + printf("%d %d\n", running_flag, c); + if (running_flag == false && c == 3) // ^c *interrupt_emulation = *terminate = true; else if (running_flag == true && c == 5) // ^e diff --git a/console.h b/console.h index d030a66..5ab1d2b 100644 --- a/console.h +++ b/console.h @@ -34,6 +34,8 @@ protected: uint8_t tx { 0 }; uint8_t ty { 0 }; + std::string debug_buffer; + virtual int wait_for_char_ll(const short timeout) = 0; virtual void put_char_ll(const char c) = 0;