Hi,
For those interested I've published a command interpreter some time ago that allows you to define commands, parameter lists and their descriptions.
Demo of the Cmdb Command Interpreter.
Replaces the old cmbd demo as it had name clashes on this website.
Commands can be organised in subsystems (you always see zero or one subsystem together with global commands).
Implementing the commands is done in a switch statement and parameters can be easily accessed after they are parsed.
The cmdb library takes care of parsing commands, generating help, ASCII handling (backspace and previous command) and has a simple option for macros.
Adding a command is a simple two step process,
- Add a command definition to the cmds table
- Implement a case statement in the dispatcher routine.
Some (global) commands are handled by the cmdb library internally like 'Help' and 'Idle'. The library also has a number of predefined commands you can add like 'Boot' and Macro Support.
After that it's a matter of feeding the interpreter with serial input.
My main use for this library is to create small & simple pieces of functionality (like setting a PWM port with a command like 'PWM 3 100 10' which sets PWM port 3 to 100ms period with 10% duty cycle) that I can call from a controlling PC.
This keeps my embedded software simple (modular) and not a giant monolithic piece of software. The command interpreter approach makes it also easy to test by hand with good old hyper-terminal or similar programs.
Suggestions or bug reports are welcome!
Hi,
For those interested I've published a command interpreter some time ago that allows you to define commands, parameter lists and their descriptions.
Import programCmdb_test
Demo of the Cmdb Command Interpreter. Replaces the old cmbd demo as it had name clashes on this website.
Last commit 19 Jan 2022 by Wim van der Vegt
Commands can be organised in subsystems (you always see zero or one subsystem together with global commands).
Implementing the commands is done in a switch statement and parameters can be easily accessed after they are parsed.
The cmdb library takes care of parsing commands, generating help, ASCII handling (backspace and previous command) and has a simple option for macros.
Adding a command is a simple two step process,
Some (global) commands are handled by the cmdb library internally like 'Help' and 'Idle'. The library also has a number of predefined commands you can add like 'Boot' and Macro Support.
After that it's a matter of feeding the interpreter with serial input.
My main use for this library is to create small & simple pieces of functionality (like setting a PWM port with a command like 'PWM 3 100 10' which sets PWM port 3 to 100ms period with 10% duty cycle) that I can call from a controlling PC.
This keeps my embedded software simple (modular) and not a giant monolithic piece of software. The command interpreter approach makes it also easy to test by hand with good old hyper-terminal or similar programs.
Suggestions or bug reports are welcome!