From f5202b002f28cd2ab6ff9678b395cde89a2ae3b6 Mon Sep 17 00:00:00 2001 From: Joe Date: Mon, 15 Nov 2021 14:56:35 -0500 Subject: [PATCH 1/2] Add buffer flush after receiving printable char Add a buffer flush (when buffered output is in use) after receiving a printable char to reduce the delay between the user pressing a key and seeing the character echoed back --- Shell.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Shell.c b/Shell.c index 5286bd4..b7d8237 100644 --- a/Shell.c +++ b/Shell.c @@ -342,6 +342,12 @@ void shell_task() shellbuf[count] = rxchar; shell_putc(rxchar); count++; + + // If we're using buffered output, flush the output buffer so the user gets immediate feedback on their key press + if (obhandle->shell_bwriter != 0) + obhandle->shell_bwriter(obhandle->outbuffer, obhandle->buffercount); + // and clear counter + obhandle->buffercount = 0; } } // Check if a full command is available on the buffer to process From 94a2ef809de5ed752c21cdbfba5afe476fd814de Mon Sep 17 00:00:00 2001 From: Joe Date: Mon, 15 Nov 2021 16:03:19 -0500 Subject: [PATCH 2/2] Added null checks for obhandle and buffer flush to shell_prompt --- Shell.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/Shell.c b/Shell.c index b7d8237..06ebe8e 100644 --- a/Shell.c +++ b/Shell.c @@ -344,10 +344,12 @@ void shell_task() count++; // If we're using buffered output, flush the output buffer so the user gets immediate feedback on their key press - if (obhandle->shell_bwriter != 0) - obhandle->shell_bwriter(obhandle->outbuffer, obhandle->buffercount); + if (obhandle != 0) { + if (obhandle->shell_bwriter != 0) + obhandle->shell_bwriter(obhandle->outbuffer, obhandle->buffercount); // and clear counter obhandle->buffercount = 0; + } } } // Check if a full command is available on the buffer to process @@ -515,6 +517,14 @@ static void shell_prompt() #else shell_print((const char *) "device>"); #endif + + // If we're using buffered output, flush the output buffer so the user gets immediate feedback on their key press + if (obhandle != 0) { + if (obhandle->shell_bwriter != 0) + obhandle->shell_bwriter(obhandle->outbuffer, obhandle->buffercount); + // and clear counter + obhandle->buffercount = 0; + } } /*-------------------------------------------------------------*