UART Command Parser Time Manager Data Store for SD Card for stm32l476 [it's not Licensed as BSD/GPLx]
Dependencies: mbed SDFileSystem
include/CommandParser.h@1:71c9c97c9f3d, 2019-04-21 (annotated)
- Committer:
- Inscape_ao
- Date:
- Sun Apr 21 02:50:19 2019 +0000
- Revision:
- 1:71c9c97c9f3d
- Parent:
- 0:c347f602596d
- Child:
- 2:a694440145e9
add Reply Method in Command Parser
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Inscape_ao | 0:c347f602596d | 1 | #ifndef _COMMANDPARSER_H_ |
Inscape_ao | 0:c347f602596d | 2 | #define _COMMANDPARSER_H_ |
Inscape_ao | 0:c347f602596d | 3 | |
Inscape_ao | 0:c347f602596d | 4 | #include "UartReceiver.h" |
Inscape_ao | 0:c347f602596d | 5 | |
Inscape_ao | 1:71c9c97c9f3d | 6 | class CommandParser; |
Inscape_ao | 1:71c9c97c9f3d | 7 | |
Inscape_ao | 0:c347f602596d | 8 | typedef struct _command_parser_rule_s { |
Inscape_ao | 0:c347f602596d | 9 | char* cmdName; |
Inscape_ao | 1:71c9c97c9f3d | 10 | int(*func)(CommandParser*, char*); |
Inscape_ao | 0:c347f602596d | 11 | } CmdParseRule; |
Inscape_ao | 0:c347f602596d | 12 | |
Inscape_ao | 0:c347f602596d | 13 | class CommandParser |
Inscape_ao | 0:c347f602596d | 14 | { |
Inscape_ao | 0:c347f602596d | 15 | public: |
Inscape_ao | 0:c347f602596d | 16 | const static int CmdNameLen = 3; |
Inscape_ao | 0:c347f602596d | 17 | const static int CmdLen = sizeof(":0 CMD 0000") - 1 /* EOL */; |
Inscape_ao | 1:71c9c97c9f3d | 18 | class CmdReply |
Inscape_ao | 1:71c9c97c9f3d | 19 | { |
Inscape_ao | 1:71c9c97c9f3d | 20 | public: |
Inscape_ao | 1:71c9c97c9f3d | 21 | const static int Success = 0; |
Inscape_ao | 1:71c9c97c9f3d | 22 | const static int InvalidFmt = 1; |
Inscape_ao | 1:71c9c97c9f3d | 23 | const static int InvalidCmd = 2; |
Inscape_ao | 1:71c9c97c9f3d | 24 | const static int InvalidLen = 3; |
Inscape_ao | 1:71c9c97c9f3d | 25 | }; |
Inscape_ao | 0:c347f602596d | 26 | private: |
Inscape_ao | 0:c347f602596d | 27 | int deviceID; |
Inscape_ao | 0:c347f602596d | 28 | UartReceiver *pR; |
Inscape_ao | 0:c347f602596d | 29 | Serial *pUart; |
Inscape_ao | 0:c347f602596d | 30 | CmdParseRule *ruleTable; |
Inscape_ao | 0:c347f602596d | 31 | int ruleTableLen; |
Inscape_ao | 0:c347f602596d | 32 | private: |
Inscape_ao | 0:c347f602596d | 33 | CommandParser(void); |
Inscape_ao | 0:c347f602596d | 34 | public: |
Inscape_ao | 0:c347f602596d | 35 | CommandParser(UartReceiver *setUartReceiver, int setDeviceID, |
Inscape_ao | 0:c347f602596d | 36 | CmdParseRule *setRuleTable, int setRuleTableLen); |
Inscape_ao | 0:c347f602596d | 37 | void run(void); |
Inscape_ao | 0:c347f602596d | 38 | int parse(char *pStr); |
Inscape_ao | 1:71c9c97c9f3d | 39 | int getDeviceID(void); |
Inscape_ao | 1:71c9c97c9f3d | 40 | void reply(bool ack = true, int replyCode = 0); |
Inscape_ao | 1:71c9c97c9f3d | 41 | void reply(bool ack, char *replyStr); |
Inscape_ao | 0:c347f602596d | 42 | }; |
Inscape_ao | 0:c347f602596d | 43 | #endif /* _COMMANDPARSER_H_ */ |