Jean Mercier
/
jmPulse
Generate up to 8 different digital waeforms from serial port
jmInterpreter.c@0:374d47623fab, 2011-02-12 (annotated)
- Committer:
- jm
- Date:
- Sat Feb 12 16:41:07 2011 +0000
- Revision:
- 0:374d47623fab
jmPulse Command Line Interface Module
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
jm | 0:374d47623fab | 1 | /************************************************************************* |
jm | 0:374d47623fab | 2 | * @file jmInterpreter.c |
jm | 0:374d47623fab | 3 | * @brief Command Line Interpreter |
jm | 0:374d47623fab | 4 | * |
jm | 0:374d47623fab | 5 | * @date December 27,2010 |
jm | 0:374d47623fab | 6 | */ |
jm | 0:374d47623fab | 7 | |
jm | 0:374d47623fab | 8 | #include "jmInterpreter.h" |
jm | 0:374d47623fab | 9 | #include "jmRingBuffer.h" |
jm | 0:374d47623fab | 10 | #include "jmCommands.h" |
jm | 0:374d47623fab | 11 | |
jm | 0:374d47623fab | 12 | /** @brief Interpret a command line. |
jm | 0:374d47623fab | 13 | * Interpreter uses Command Line Buffer to fecth command name |
jm | 0:374d47623fab | 14 | * and redirects execution to associated function. |
jm | 0:374d47623fab | 15 | * @param none |
jm | 0:374d47623fab | 16 | * @returns none |
jm | 0:374d47623fab | 17 | */ |
jm | 0:374d47623fab | 18 | void Interpret(void){ |
jm | 0:374d47623fab | 19 | unsigned int i,k; |
jm | 0:374d47623fab | 20 | unsigned char Command, found; |
jm | 0:374d47623fab | 21 | char Word[WordMaxSize]; |
jm | 0:374d47623fab | 22 | Command =0; |
jm | 0:374d47623fab | 23 | found = 0; |
jm | 0:374d47623fab | 24 | |
jm | 0:374d47623fab | 25 | if(NotEmpty(pLine)){ |
jm | 0:374d47623fab | 26 | ExtractWord(pLine,Word); // Command name extraction |
jm | 0:374d47623fab | 27 | for(i=0, k=0;i<sizeof(cmdNames);i++){ // lookup in names array |
jm | 0:374d47623fab | 28 | if(cmdNames[i]!=Word[k]){ // if different |
jm | 0:374d47623fab | 29 | while(cmdNames[i]!=0)i++; // next entry in names array |
jm | 0:374d47623fab | 30 | Command++; // update command index |
jm | 0:374d47623fab | 31 | k=0; |
jm | 0:374d47623fab | 32 | } |
jm | 0:374d47623fab | 33 | else{ |
jm | 0:374d47623fab | 34 | if(Word[k]==0){ |
jm | 0:374d47623fab | 35 | found=1; |
jm | 0:374d47623fab | 36 | } |
jm | 0:374d47623fab | 37 | else k++; |
jm | 0:374d47623fab | 38 | } //else |
jm | 0:374d47623fab | 39 | |
jm | 0:374d47623fab | 40 | if(found)break; |
jm | 0:374d47623fab | 41 | } //for |
jm | 0:374d47623fab | 42 | } |
jm | 0:374d47623fab | 43 | |
jm | 0:374d47623fab | 44 | // Command execution |
jm | 0:374d47623fab | 45 | Action(Command); |
jm | 0:374d47623fab | 46 | } |