From 2bc54edaf3b0824962e1699acca3dd8ba14c3f01 Mon Sep 17 00:00:00 2001 From: patacongo Date: Sat, 25 Feb 2012 20:46:18 +0000 Subject: [PATCH] readline() (and hence NSH) now accept the DEL character as well as the Backspace character for the backspace functionality git-svn-id: https://nuttx.svn.sourceforge.net/svnroot/nuttx/trunk@4428 7fd9a85b-ad96-42d3-883c-3090e2eb8679 --- apps/ChangeLog.txt | 4 ++++ apps/system/readline/readline.c | 29 ++++++++++++++++++----- nuttx/ChangeLog | 2 ++ nuttx/configs/stm3240g-eval/README.txt | 22 ++++++++++++++++- nuttx/configs/stm32f4discovery/README.txt | 21 ++++++++++++++++ 5 files changed, 71 insertions(+), 7 deletions(-) diff --git a/apps/ChangeLog.txt b/apps/ChangeLog.txt index 5a11745967..89703967fa 100755 --- a/apps/ChangeLog.txt +++ b/apps/ChangeLog.txt @@ -192,3 +192,7 @@ * apps/examples/qencoder: Add a quadrature driver test. * apps/examples/ostest/fpu.c: Add a test to verify that FPU registers are properly saved and restored on context switches. + * apps/system/readline/readline.c: readline() will now treat either a + backspace or a DEL character as a backspace (i.e., deleting the character + to the left of the cursor). This makes NSH less dependent on particular + keyboard mappings of the Backspace key. Submitted by Mike Smith. diff --git a/apps/system/readline/readline.c b/apps/system/readline/readline.c index 4cd29c16f7..97bdf65020 100644 --- a/apps/system/readline/readline.c +++ b/apps/system/readline/readline.c @@ -68,6 +68,13 @@ #undef CONFIG_EOL_IS_BOTH_CRLF #define CONFIG_EOL_IS_EITHER_CRLF 1 +/* Some special characters */ + +#define BS 0x08 /* Backspace */ +#define ESC 0x1b /* Escape */ +#define LBRACKET 0x5b /* Left bracket */ +#define DEL 0x7f /* DEL */ + /**************************************************************************** * Private Type Declarations ****************************************************************************/ @@ -219,7 +226,7 @@ ssize_t readline(FAR char *buf, int buflen, FILE *instream, FILE *outstream) { /* Yes, is it an [, 3 byte sequence */ - if (ch != 0x5b || escape == 2) + if (ch != LBRACKET || escape == 2) { /* We are finished with the escape sequence */ @@ -238,9 +245,16 @@ ssize_t readline(FAR char *buf, int buflen, FILE *instream, FILE *outstream) } } - /* Check for backspace */ + /* Check for backspace + * + * There are several notions of backspace, for an elaborate summary see + * http://www.ibb.net/~anne/keyboard.html. There is no clean solution. + * Here both DEL and backspace are treated like backspace here. The + * Unix/Linux screen terminal by default outputs DEL (0x7f) when the + * backspace key is pressed. + */ - else if (ch == 0x08) + else if (ch == BS || ch == DEL) { /* Eliminate that last character in the buffer. */ @@ -249,9 +263,12 @@ ssize_t readline(FAR char *buf, int buflen, FILE *instream, FILE *outstream) nch--; #ifdef CONFIG_READLINE_ECHO - /* Echo the backspace character on the console */ + /* Echo the backspace character on the console. Always output + * the backspace character because the VT100 terminal doesn't + * understand DEL properly. + */ - readline_consoleputc(ch, outfd); + readline_consoleputc(BS, outfd); readline_consoleputs(g_erasetoeol, outfd); #endif } @@ -259,7 +276,7 @@ ssize_t readline(FAR char *buf, int buflen, FILE *instream, FILE *outstream) /* Check for the beginning of a VT100 escape sequence */ - else if (ch == 0x1b) + else if (ch == ESC) { /* The next character is escaped */ diff --git a/nuttx/ChangeLog b/nuttx/ChangeLog index fa85503efc..496c751e81 100644 --- a/nuttx/ChangeLog +++ b/nuttx/ChangeLog @@ -2506,3 +2506,5 @@ submitted by Max Nekludov. * arch/arm/src/armv7-m/up_fpu.S and arch/arm/src/stm32/stm32_vectors.S: Fix lazy FPU register saving with CONFIG_ARCH_FPU is set in the configuration. + * arch/arm/src/armv7-m: Lazy saving of floating point registers on context + switches now seems to be functional. diff --git a/nuttx/configs/stm3240g-eval/README.txt b/nuttx/configs/stm3240g-eval/README.txt index 34c6a09f3f..7ecbd71b5a 100755 --- a/nuttx/configs/stm3240g-eval/README.txt +++ b/nuttx/configs/stm3240g-eval/README.txt @@ -909,8 +909,28 @@ Where is one of the following: examples/ostest. By default, this project assumes that you are using the DFU bootloader. - CONFIG_STM32_CODESOURCERYW=y : CodeSourcery under Windows + CONFIG_STM32_CODESOURCERYW=y : CodeSourcery under Windows + If you use the Atollic toolchain, then the FPU test can be enabled in the + examples/ostest by adding the following your NuttX configuration file: + + -CONFIG_ARCH_FPU=n : Enabled the FPU + +CONFIG_ARCH_FPU=y + + -CONFIG_STM32_CODESOURCERYW=y : Disable CodeSourcery under Windows + +CONFIG_STM32_CODESOURCERYL=n + + -CONFIG_STM32_ATOLLIC=y : Enable the Atollic toolchain + +CONFIG_STM32_ATOLLIC=n + + -CONFIG_SCHED_WAITPID=y : Enable the waitpid() API needed by the FPU test + +CONFIG_SCHED_WAITPID=n + + The FPU test also needs to know the size of the FPU registers save area in + bytes (see arch/arm/include/armv7-m/irq_lazyfpu.h): + + -CONFIG_EXAMPLES_OSTEST_FPUSIZE=(4*33) + telnetd: -------- diff --git a/nuttx/configs/stm32f4discovery/README.txt b/nuttx/configs/stm32f4discovery/README.txt index 70075220a0..1048e54ace 100755 --- a/nuttx/configs/stm32f4discovery/README.txt +++ b/nuttx/configs/stm32f4discovery/README.txt @@ -711,6 +711,27 @@ Where is one of the following: CONFIG_STM32_CODESOURCERYW=y : CodeSourcery under Windows + + If you use the Atollic toolchain, then the FPU test can be enabled in the + examples/ostest by adding the following your NuttX configuration file: + + -CONFIG_ARCH_FPU=n : Enabled the FPU + +CONFIG_ARCH_FPU=y + + -CONFIG_STM32_CODESOURCERYW=y : Disable CodeSourcery under Windows + +CONFIG_STM32_CODESOURCERYL=n + + -CONFIG_STM32_ATOLLIC=y : Enable the Atollic toolchain + +CONFIG_STM32_ATOLLIC=n + + -CONFIG_SCHED_WAITPID=y : Enable the waitpid() API needed by the FPU test + +CONFIG_SCHED_WAITPID=n + + The FPU test also needs to know the size of the FPU registers save area in + bytes (see arch/arm/include/armv7-m/irq_lazyfpu.h): + + -CONFIG_EXAMPLES_OSTEST_FPUSIZE=(4*33) + nsh: --- Configures the NuttShell (nsh) located at apps/examples/nsh. The