File tree Expand file tree Collapse file tree 3 files changed +22
-2
lines changed Expand file tree Collapse file tree 3 files changed +22
-2
lines changed Original file line number Diff line number Diff line change @@ -13,7 +13,7 @@ It targets communication with embedded systems from remote terminal to quickly s
1313* Written in C language (C99)
1414* No dynamic allocation, maximum number of commands assigned at compile time
1515* Highly configurable
16- * Simple help-text with ` cmd -v ` option
16+ * Simple help-text with ` cmd -h ` option
1717* User friendly MIT license
1818
1919## Contribute
Original file line number Diff line number Diff line change 33#include <string.h>
44#include <stdint.h>
55
6+ /**
7+ * \brief Reading one character at a time
8+ *
9+ * This is useful to test the shell in a "raw" mode (non-canonical input)
10+ * Please note that conio.h is a windows only header
11+ */
12+ #ifndef LWSHELL_TEST_READ_SINGLE_CHAR
13+ #define LWSHELL_TEST_READ_SINGLE_CHAR 0
14+ #endif
15+
16+ #if LWSHELL_TEST_READ_SINGLE_CHAR
17+ #include <conio.h>
18+ #endif
19+
620void example_minimal (void );
721
822int32_t
@@ -89,7 +103,13 @@ main(void) {
89103 printf ("Start entering your command and press enter...\r\n" );
90104 while (1 ) {
91105 char str [255 ];
106+
107+ #if LWSHELL_TEST_READ_SINGLE_CHAR
108+ str [0 ] = getch ();
109+ str [1 ] = '\0' ;
110+ #else
92111 fgets (str , sizeof (str ), stdin );
112+ #endif
93113
94114 /* Insert input to library */
95115 lwshell_input (str , strlen (str ));
Original file line number Diff line number Diff line change @@ -285,8 +285,8 @@ lwshell_input(const void* in_data, size_t len) {
285285 case LWSHELL_ASCII_BACKSPACE : {
286286 /* Try to delete character from buffer */
287287 if (lw -> buff_ptr > 0 ) {
288- lw -> buff [lw -> buff_ptr ] = '\0' ;
289288 -- lw -> buff_ptr ;
289+ lw -> buff [lw -> buff_ptr ] = '\0' ;
290290 LW_OUTPUT (lw , "\b \b" );
291291 }
292292 break ;
You can’t perform that action at this time.
0 commit comments