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