UART Command Parser Time Manager Data Store for SD Card for stm32l476 [it's not Licensed as BSD/GPLx]
Dependencies: mbed SDFileSystem
Diff: include/CommandParser.h
- Revision:
- 2:a694440145e9
- Parent:
- 1:71c9c97c9f3d
- Child:
- 19:36072b9b79f3
diff -r 71c9c97c9f3d -r a694440145e9 include/CommandParser.h --- a/include/CommandParser.h Sun Apr 21 02:50:19 2019 +0000 +++ b/include/CommandParser.h Tue Apr 23 08:47:11 2019 +0000 @@ -5,16 +5,25 @@ class CommandParser; +/** + * Parsing Rules + * if (cmdName) CALL func with exarg. + */ typedef struct _command_parser_rule_s { char* cmdName; - int(*func)(CommandParser*, char*); + int(*func)(CommandParser*, char*, int); + int exarg; } CmdParseRule; +/* CommandParser */ class CommandParser { public: + /* CMD length */ const static int CmdNameLen = 3; + /* CMD total length */ const static int CmdLen = sizeof(":0 CMD 0000") - 1 /* EOL */; + /* reply code (for ACK/NAK) */ class CmdReply { public: @@ -30,14 +39,23 @@ CmdParseRule *ruleTable; int ruleTableLen; private: + /* (INVALIDED) constructor */ CommandParser(void); public: + /* constructor */ CommandParser(UartReceiver *setUartReceiver, int setDeviceID, CmdParseRule *setRuleTable, int setRuleTableLen); + /* start parsing */ void run(void); + /* process parsing */ int parse(char *pStr); + /* get my Device ID */ int getDeviceID(void); + /* generate ACK/NAK with int code */ void reply(bool ack = true, int replyCode = 0); + /* generate ACK/NAK with String */ void reply(bool ack, char *replyStr); + /* get currentUart */ + Serial *getCurrentUart(void); }; #endif /* _COMMANDPARSER_H_ */ \ No newline at end of file