Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem


FreeRTOS + CLI: Command Line Editing

Posted by Roland A.I. Rosier on February 28, 2013
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.

RE: FreeRTOS + CLI: Command Line Editing

Posted by Jerry Durand on February 28, 2013
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.

RE: FreeRTOS + CLI: Command Line Editing

Posted by Jerry Durand on February 28, 2013
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.

RE: FreeRTOS + CLI: Command Line Editing

Posted by Richard Damon on February 28, 2013
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.

RE: FreeRTOS + CLI: Command Line Editing

Posted by Richard on February 28, 2013
I think most, if not actually *all* FreeRTOS+CLI examples process the backsapce character, but that is the only special character that is processed.


RE: FreeRTOS + CLI: Command Line Editing

Posted by Roland A.I. Rosier on March 12, 2013
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.

[ Back to the top ]    [ About FreeRTOS ]    [ Privacy ]    [ Sitemap ]    [ ]

Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.

Latest News

NXP tweet showing LPC5500 (ARMv8-M Cortex-M33) running FreeRTOS.

Version 10.1.1 of the FreeRTOS kernel is available for immediate download. MIT licensed.

View a recording of the "OTA Update Security and Reliability" webinar, presented by TI and AWS.


FreeRTOS and other embedded software careers at AWS.

FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Espressif ESP32

IAR Partner

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers


STMicro RTOS partner supporting ARM7, ARM Cortex-M3, ARM Cortex-M4 and ARM Cortex-M0

Texas Instruments MCU Developer Network RTOS partner for ARM and MSP430 microcontrollers

OpenRTOS and SafeRTOS

Xilinx Microblaze and Zynq partner