xrocusOS_ADXL355 version
Dependencies: mbed SDFileSystem
include/CommandParser.h
- Committer:
- Inscape_ao
- Date:
- 2019-04-21
- Revision:
- 1:71c9c97c9f3d
- Parent:
- 0:c347f602596d
- Child:
- 2:a694440145e9
File content as of revision 1:71c9c97c9f3d:
#ifndef _COMMANDPARSER_H_ #define _COMMANDPARSER_H_ #include "UartReceiver.h" class CommandParser; typedef struct _command_parser_rule_s { char* cmdName; int(*func)(CommandParser*, char*); } CmdParseRule; class CommandParser { public: const static int CmdNameLen = 3; const static int CmdLen = sizeof(":0 CMD 0000") - 1 /* EOL */; class CmdReply { public: const static int Success = 0; const static int InvalidFmt = 1; const static int InvalidCmd = 2; const static int InvalidLen = 3; }; private: int deviceID; UartReceiver *pR; Serial *pUart; CmdParseRule *ruleTable; int ruleTableLen; private: CommandParser(void); public: CommandParser(UartReceiver *setUartReceiver, int setDeviceID, CmdParseRule *setRuleTable, int setRuleTableLen); void run(void); int parse(char *pStr); int getDeviceID(void); void reply(bool ack = true, int replyCode = 0); void reply(bool ack, char *replyStr); }; #endif /* _COMMANDPARSER_H_ */