Jean Mercier / Mbed 2 deprecated jmBridge
Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers jmInterpreter.c Source File

jmInterpreter.c

00001 /*************************************************************************
00002  * @file     jmInterpreter.c
00003  * @brief    Command Line Interpreter
00004  *                  
00005  * @date    December 27,2010 
00006 */
00007 
00008 #include "jmInterpreter.h"
00009 #include "jmRingBuffer.h"
00010 #include "jmCommands.h"
00011 
00012 /** @brief Interpret a command line.
00013  * Interpreter uses Command Line Buffer to fecth command name
00014  * and redirects execution to associated function.
00015  * @param none
00016  * @returns none
00017  */
00018 void Interpret(void){ 
00019   unsigned int i,k;
00020   unsigned char Command, found;
00021   char Word[WordMaxSize];
00022   Command =0;
00023   found = 0;
00024   
00025   if(NotEmpty(pLine)){
00026      ExtractWord(pLine,Word);              // Command name extraction 
00027      for(i=0, k=0;i<sizeof(cmdNames);i++){ // lookup in names array
00028          if(cmdNames[i]!=Word[k]){         // if different
00029             while(cmdNames[i]!=0)i++;      // next entry in names array
00030             Command++;                     // update command index
00031             k=0;
00032          }
00033          else{
00034            if(Word[k]==0){             
00035               found=1; 
00036             } 
00037            else k++;
00038          } //else
00039     
00040          if(found)break; 
00041      }  //for
00042    }
00043   
00044   // Command execution
00045   Action(Command);
00046 }