
mbed2 pre-final
Dependencies: LCD_DISCO_F429ZI mbed BSP_DISCO_F429ZI
Diff: token_decoder.h
- Revision:
- 2:7dc265489818
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/token_decoder.h Sun Jun 14 11:13:56 2020 +0000 @@ -0,0 +1,37 @@ +#ifndef TOKEN_DECODER_H +#define TOKEN_DECODER_H + +#define MAX_TOKEN_NR 2 +#define MAX_KEYWORD_NR 4 +#define MAX_KEYWORD_STRING_LTH 20 + +typedef enum TokenType {KEYWORD, NUMBER, STRING} TokenType; +typedef enum KeywordCode {ID, CALIB, GOTO, STEP} KeywordCode; +enum Result {OK, ERR}; + +typedef union TokenValue { + enum KeywordCode eKeyword; + unsigned int uiNumber; + char * pcString; +} TokenValue; + +typedef struct Token { + enum TokenType eType; + union TokenValue uValue; +} Token; + +typedef struct Keyword { + enum KeywordCode eCode; + char cString[MAX_KEYWORD_STRING_LTH + 1]; +} Keyword; + +class TokenDecoder { + public: + void DecodeMsg(char *pcString); + private: + unsigned char ucFindTokensInString(char *pcString); + enum Result eStringToKeyword (char pcStr[], enum KeywordCode *peKeywordCode); + void DecodeTokens(void); +}; + +#endif