![](/media/cache/profiles/0f0ee3310223fe38a989b2c818709393.50x50_q85.jpg)
Control up to 4 steppers axis with limit switch logic from serial port
Diff: jmInterpreter.c
- Revision:
- 0:3e676fcd9c71
diff -r 000000000000 -r 3e676fcd9c71 jmInterpreter.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jmInterpreter.c Sat Feb 12 16:49:03 2011 +0000 @@ -0,0 +1,46 @@ +/************************************************************************* + * @file jmInterpreter.c + * @brief Command Line Interpreter + * + * @date December 27,2010 +*/ + +#include "jmInterpreter.h" +#include "jmRingBuffer.h" +#include "jmCommands.h" + +/** @brief Interpret a command line. + * Interpreter uses Command Line Buffer to fecth command name + * and redirects execution to associated function. + * @param none + * @returns none + */ +void Interpret(void){ + unsigned int i,k; + unsigned char Command, found; + char Word[WordMaxSize]; + Command =0; + found = 0; + + if(NotEmpty(pLine)){ + ExtractWord(pLine,Word); // Command name extraction + for(i=0, k=0;i<sizeof(cmdNames);i++){ // lookup in names array + if(cmdNames[i]!=Word[k]){ // if different + while(cmdNames[i]!=0)i++; // next entry in names array + Command++; // update command index + k=0; + } + else{ + if(Word[k]==0){ + found=1; + } + else k++; + } //else + + if(found)break; + } //for + } + + // Command execution + Action(Command); +}