From 9cb13f6158e223ec0757b6546add37d5f2de3115 Mon Sep 17 00:00:00 2001 From: NicknineTheEagle Date: Thu, 19 Mar 2020 20:12:28 +0300 Subject: [PATCH] Fix a bug with backspace handling in modem Fixes a bug where entering backspace while command buffer was already empty added backspace char to the buffer thus screwing it up. --- src/hardware/serialport/softmodem.cpp | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/hardware/serialport/softmodem.cpp b/src/hardware/serialport/softmodem.cpp index bc5955f3..d5a97867 100644 --- a/src/hardware/serialport/softmodem.cpp +++ b/src/hardware/serialport/softmodem.cpp @@ -718,11 +718,17 @@ void CSerialModem::Timer2(void) { rqueue->addb(txval); //LOG_MSG("Echo back to queue: %x",txval); } - if (txval == 0xa) continue; //Real modem doesn't seem to skip this? - else if (txval == 0x8 && (cmdpos > 0)) --cmdpos; // backspace - else if (txval == 0xd) DoCommand(); // return - else if (txval != '+') { - if(cmdpos<99) { + + if (txval == '\n') + continue; // Real modem doesn't seem to skip this? + + if (txval == '\b') { + if (cmdpos > 0) + cmdpos--; + } else if (txval == '\r') { + DoCommand(); + } else if (txval != '+') { + if (cmdpos < 99) { cmdbuf[cmdpos] = txval; cmdpos++; }