![](/media/cache/profiles/799fc232a527e7a7d6435c945083a329.50x50_q85.jpg)
Demo of the Cmdb Command Interpreter. Replaces the old cmbd demo as it had name clashes on this website.
Diff: main.cpp
- Revision:
- 1:4e699312b5c8
- Parent:
- 0:7b62ec9a3f53
diff -r 7b62ec9a3f53 -r 4e699312b5c8 main.cpp --- a/main.cpp Fri Feb 11 12:31:18 2011 +0000 +++ b/main.cpp Wed Feb 15 09:52:18 2012 +0000 @@ -8,8 +8,8 @@ //We'll be using the Usb Serial port Serial serial(USBTX, USBRX); //tx, rx -#define CID_TEST 1 -#define CID_INT 2 +#define CID_TEST (int)1 +#define CID_INT (int)2 /** Sample User Command Dispatcher. * @@ -26,8 +26,8 @@ } } -const cmd c1("Test",SUBSYSTEM,CID_TEST,"" ,"* Test Subsystem"); -const cmd c2("Int" ,CID_TEST ,CID_INT ,"%i","* Int as parameter" ,"dummy"); +static const cmd c1 = {"Test",SUBSYSTEM,CID_TEST,"" ,"* Test Subsystem"}; +static const cmd c2 = {"Int" ,CID_TEST ,CID_INT ,"%i","* Int as parameter" ,"dummy"}; int main() { // Set the Baudrate. @@ -62,6 +62,9 @@ //Create and initialize the Command Interpreter. Cmdb cmdb(serial, cmds, &my_dispatcher); + cmdb.printf("%d=%d\r\n",cmds[0].subs,cmds[0].cid); + cmdb.printf("%d=%d\r\n",cmds[1].subs,cmds[1].cid); + while (1) { //Check for input... if (cmdb.hasnext()==true) { @@ -85,8 +88,8 @@ while (cmdb.macro_hasnext()) { //Get and process next character. cmdb.scan(cmdb.macro_next()); - - //After the last character we need to add a cr to force execution. + + //After the last character we need to add a cr to force execution. if (!cmdb.macro_peek()) { cmdb.scan(cr); }