A command line handler for embedded devices.
This supports a variety of useful features, aimed at user friendly-ness, without an excessive overhead for an embedded devices.
Arguments are described in data alongside your functions. This means arguments can be validated and parsed to the appropriate types before your funcition is called.
The following argument types are supported:
- Numbers:
9600
- Hex
0x2580
- Engineering notation
9k6
- Hex
- Booleans
0
or1
- Strings
'Hey'
- Python style escape sequences
"\"Hey\"\r\x0A"
- Python style escape sequences
- Byte arrays
6865790d0a
or[68 65 79 0D 0A]
(and more)
Menus are built out of nodes, which may in turn be functions or more menus. This leads to a natural command tree.
─ root
├─ spi
│ ├─ read(number)
│ └─ write(bytes)
├─ uart
│ ├─ read(number)
│ └─ write(bytes)
└─ version()
For example, a valid command may be uart write 'hello world'
While this could be used for machine interfaces - this module is targeted at human use. Entering commands should be forgiving, and rich in feedback. The menus can be explored without needing to know the exact syntax or arguments.
The following features support this.
- Input Echo
- Backspace
- Colors for warnings and errors
- Bell for errors & halts
- Tab completion
- A symbol
?
to get information about a menu or function - Error messages to describe any parsing failures.
- Add
/Src/
to your build and include directories - Copy
/Templates/CmdConf.h
into your project, and modify to suit #include "Cmd.h"
in your files and get to work
An example based around STM32X on can be found here