FreeRTOS + CLI: Command Line Editing

Hello all, Could I ask if anyone knows of a CLI for FreeRTOS which includes some form of Command Line Editing. By this I mean that if someone types control characters like the “Backspace” button, that this is processed correctly by the Command Line. I suspect that I would need at a bare minimum the ability to use Backspace on a Command Line.

FreeRTOS + CLI: Command Line Editing

I’ve wrote my own long ago and just cut, paste, and modify as needed for each new project.  Some projects need to respond to special characters so I normally need to change at least something (ex: one project uses ‘*’ to clear the buffer and abort any ongoing operation and ‘~’ to send binary data to a background task).  One thing in common with mine is when I receive a RETURN ‘r’ that locks the buffer and begins whatever parsing is needed for the application.  All editing like backspace and other special characters is done between my incoming ring buffer and the command buffer. It’s not really that hard, just decide what you need it to do and write it to your satisfaction. 

FreeRTOS + CLI: Command Line Editing

Slight correction, the special characters for abort and binary data are done in the interrupt so they’re pulled from the data stream as soon as they come in.  They are never even put into the buffer.

FreeRTOS + CLI: Command Line Editing

What I have often done for cases like this is have (small) pool of buffers, and the serial interrupt builds up the line being typed into one of them (processing backspaces and clear line commands, etc) , and on the end of line character, sends the pointer to that buffer to the waiting task, and get the next buffer. When the task is done processing the buffer, it returns it to the list of available buffers. This way there isn’t a “dead time” for receiving characters after the End of Line (unless you get so far ahead that you run out of buffers). This allows the command line processor to spawn copies of itself if needed to run a long command without killing the command input stream.

FreeRTOS + CLI: Command Line Editing

I think most, if not actually *all* FreeRTOS+CLI examples process the backsapce character, but that is the only special character that is processed. Regards.

FreeRTOS + CLI: Command Line Editing

Thank you all for your replies. For information I found out what the issue was; the FreeRTOS CLI as used by the Atmel A.S.F. 3.5.1 does not fully handle backspace as sent by all potential terminal emulators. My Windows 7 Terminal Emulator is PuTTY.  When I press Backspace (’b’ or 0x08), PuTTY sends Erase (0x7F). The Atmel A.S.F. 3.5.1 does not respond to 0x7F in any special way; it only responds to ‘b’ in a special way and for all other characters it echoes it back to the terminal. PuTTY responds to receiving the echoed 0x7F by performing a destructive backspace.  So it looks as though everything is fine and working. Sadly when return is pressed, the 0x7F characters in the command string are passed through to FreeRTOS CLI and mess up the command string matching. As a result, it appears that Backspace doesn’t work when FreeRTOS CLI is asked to parse the command.