The KCMD Command Processor PDF Print E-mail
Written by Administrator   
Sunday, 14 June 2009 23:55

The KCMD Command Processor

Canvas with command prompt on it Introduction

What is it?

Kcmd is a free, open source, 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
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 ..|...\

KCMD features

  • Easy to Setup -- for Any IO Just write the 4 basic IO functions in c as in- putch() getch() kbhit() putstr()
  • Designed to be Portable -- KCmd is written in straight C. Just one include file customizes kcmd for your platform.
  • Small RAM Usage -- KCmd is designed to run on 8-bit cpus. A few hundred bytes should be sufficient.
  • Easy to Add Commands -- Commands are just C functions. Add your command to the list with an easy macro.
  • Your Additions are Modular -- Keep your command sets in a folder; You only need one include-line to add a command set.
  • Open Source -- KCmd is free, and you have the source code to everything.


Downloading KCMD

   KCMD is available in source code for by click HERE.


Using KCMD

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.
What is KCMD Good For?
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


Last Updated on Monday, 15 June 2009 00:30

Sponsored Links

Bold Inventions, Powered by Joomla!; Joomla templates by SG web hosting