Chandan Siyag / Mbed 2 deprecated AlooMBED

Dependencies:   MCP23017 TCS3472_I2C WattBob_TextLCD mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers commander.h Source File

commander.h

00001 //
00002 // commander.h
00003 // Created by Chandan Siyag on 14/11/2015.
00004 //
00005 // Parses and executes commands received from the PC.
00006 //
00007 
00008 #include "globals.h"
00009 
00010 #ifndef _commander_h_
00011 #define _commander_h_
00012 
00013 const int kMaxCommandCount = 10;
00014 enum CommandObjectRaw { InvalidObject = -1, MBED = 0, PC = 1, ColourSensor = 2, Servos = 3, Port = 4, BreakBeam = 5 };
00015 extern std::string CommandObjectValue [6];
00016 extern std::string CommandObjectCommandsValue [6][kMaxCommandCount];
00017 
00018 
00019 class Commander {
00020 public:
00021     Commander();
00022     
00023     CommandTypeRaw typeRaw;
00024     char typeChar;
00025     CommandObjectRaw objectRaw;
00026     std::string object;
00027     std::string command[kMaxCommandCount - 1];
00028     std::string commandValue[kMaxCommandCount - 1];
00029     int commandIndex[kMaxCommandCount -1];
00030     bool replyCommands;
00031     
00032     void decodeCommand(CommandTypeRaw type);
00033     std::string description();
00034     
00035     virtual ~Commander();
00036     
00037 private:
00038     void readCommandObject();
00039     bool readCommand(CommandObjectRaw objectRaw);
00040     void executeCommand();
00041     void resetVariables();
00042 };
00043 
00044 #endif