Patch: Backspace characters in the shell

ChibiOS public support forum for all topics not covered by a specific support forum.

Moderators: RoccoMarco, lbednarz, tfAteba

Post Reply
jbrandmeyer
Posts: 5
Joined: Thu Oct 09, 2014 3:34 pm

Patch: Backspace characters in the shell

Post by jbrandmeyer »

By default, the PuTTY communication client (my go-to client for serial communications) sends 127 (^?) for the backspace character. Because the shell currently just echoes the character back, it visually appears as though the preceeding character was deleted. However the shell's buffer just fills up with ^? instead. Of course, this doesn't parse well, and the user is left with the impression that the shell doesn't actually handle the backspace character at all.

This impression is easily fixed by handling ^? the same as ^H.

Code: Select all

--- a/os/various/shell.c   Wed Oct 08 15:25:21 2014 -0600
+++ b/os/various/shell.c   Thu Oct 09 08:39:39 2014 -0600
@@ -284,7 +284,7 @@
       chprintf(chp, "^D");
       return TRUE;
     }
-    if (c == 8) {
+    if (c == 8 || c == 127) {
       if (p != line) {
         chSequentialStreamPut(chp, c);
         chSequentialStreamPut(chp, 0x20);


Of course, PuTTY can be configured to send ^H instead as a workaround. But this fact was not at all obvious initially.
User avatar
Giovanni
Site Admin
Posts: 14893
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: Patch: Backspace characters in the shell

Post by Giovanni »

Hi,

Change committed in 3.0.0trunk and 2.6.x.

Giovanni
Post Reply