Kcmd is a very small command processor. It is designed so that very small systems which can accept characters typed by a user and display characters for the user to read have a minimal system for accepting and executing commands. KCMD is designed to run on cpus ranging from 8-bit systems with a few hundred bytes of RAM, but of course will run fine on larger systems too, including a Desktop PC with 4 Gb of RAM also.
A user can add the source code to their embedded project, change a few settings, write four very simple character 'get' and 'put' C functions, and then have an interactive command line processor for their application.
In the below example of kcmd running, we type a command to dump 48 bytes of memory starting at address 0x138. Then we as to see what is in location 0x138, and then we type 'help' to get list of commands..
Example kcmd session running on a AVR development board (User-typed characters are in blue):
KCMD Command Processor Demo
from www.boldinventions.com
Type help for help
PROMPT> 0x130 0x38 bdump
|00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f
--------------------------------------------------------|----------------
0x0130 |28 06 2F 01 5C 07 2C 01 4C 01 7C 09 4E 01 5C 07 (./.\.,.L.|.N.\.
0x0140 |36 01 71 01 A4 08 73 01 5C 07 40 01 98 01 FA 09 6.q...s.\.@.....
0x0150 |9A 01 5C 07 4A 01 C3 01 F7 09 C7 01 5C 07 54 01 ..\.J.......\.T.
0x0160 |EE 01 7C 09 F3 01 5C 07 ..|...\.
PROMPT> 0x138 ? 332 (0x14c)
PROMPT> help
help [] -- [] This Help Command
spewAvgAdc [] -- [] Spew Adc data until kbhit
spewAdc [] -- [] Spew Adc data until kbhit
printStatus [] -- [] types out ADC status
bdump [addr][count] -- [] displays memory contents
base [n] -- [] set number base to n
memstat [] -- [] types out memory status info
Using KCMD is easy. Commands can be simple words like 'help', or they can take parameters, like '0x130 0x38 bdump'. Commands that require numeric parameters expect them before the command. 'bdump' is a command to print the contents of a range of memory locations, so the user can look at memory contents. This command takes two parameters. The first is the memory address to look at. The second is the number of bytes to display.
Commands can have any number of parameters, up to the maximum provided for in the configuration file. The default stack depth is 8.
Some readers may notice the similarity of KCMD to the FORTH programming language. It is similar, but of course KCMD only implements a few words. It is not a programming or scripting language.
KCMD is good for getting up and running very quickly on a small embedded system. It gives a very quick path to getting past the 'Hello, World' stage to a interactive environment to test out little bits of software. Even if you do not have a debugger running, KCMD will be invaluable, as you can inspect variables and/or CPU registers, you can run little commands of your own interactively and test the results.
Even if you have a wonderful debug environment, KCMD still lets you execute various bits of code interactively, and will prove to be a very useful tool.
Beyond that, KCMD can be of use any time you need a simple command processor in a project. It has very modest requirements, is easy to port to different platforms, and is very easy to write commands for.
Getting Started 1 - Creating a Hello, World project using the free version of Microsoft Visual C++ 2008
Getting Started 2 - Adding the KCMD source to the project
Getting Started 3 - Adding a few lines of code, and getting it working.
Getting Started 4 - The basics of using KCMD
Custom Stuff - Adding your own Commands to the Project
FAQ - Frequently Asked Questions