AGH UST MBED part 2

Dependencies:   LCD_DISCO_F429ZI mbed BSP_DISCO_F429ZI

Committer:
matis755
Date:
Fri May 22 07:21:44 2020 +0000
Revision:
5:3c19c3ae6286
Parent:
4:e48aee3e8d09
Add GUI,; Get ready to deploy

Who changed what in which revision?

UserRevisionLine numberNew contents of line
matis755 4:e48aee3e8d09 1 #ifndef DECODER
matis755 4:e48aee3e8d09 2 #define DECODER
matis755 4:e48aee3e8d09 3
matis755 5:3c19c3ae6286 4
matis755 4:e48aee3e8d09 5 #include "mbed.h"
matis755 4:e48aee3e8d09 6
matis755 5:3c19c3ae6286 7
matis755 4:e48aee3e8d09 8 #define NULL 0
matis755 4:e48aee3e8d09 9 #define TERMINATOR '\r'
matis755 4:e48aee3e8d09 10 #define DELIMITER_CHAR 0x20
matis755 4:e48aee3e8d09 11
matis755 4:e48aee3e8d09 12 #define HEX_bm 0x000F
matis755 4:e48aee3e8d09 13 #define MAX_TOKEN_NR 2
matis755 4:e48aee3e8d09 14 #define MAX_KEYWORD_STRING_LTH 6
matis755 4:e48aee3e8d09 15 #define MAX_KEYWORD_NR 4
matis755 4:e48aee3e8d09 16
matis755 4:e48aee3e8d09 17 typedef enum TokenType
matis755 4:e48aee3e8d09 18 {KEYWORD, NUMBER, STRING} TokenType;
matis755 4:e48aee3e8d09 19
matis755 4:e48aee3e8d09 20 typedef enum KeywordCode
matis755 4:e48aee3e8d09 21 { ID, CLB, GT, ST } KeywordCode;
matis755 4:e48aee3e8d09 22
matis755 4:e48aee3e8d09 23 typedef union TokenValue
matis755 4:e48aee3e8d09 24 {
matis755 4:e48aee3e8d09 25 enum KeywordCode eKeyword;
matis755 4:e48aee3e8d09 26 unsigned int uiNumber;
matis755 4:e48aee3e8d09 27 char *pcString;
matis755 4:e48aee3e8d09 28 } TokenValue;
matis755 4:e48aee3e8d09 29
matis755 4:e48aee3e8d09 30 typedef struct Token
matis755 4:e48aee3e8d09 31 {
matis755 4:e48aee3e8d09 32 enum TokenType eType;
matis755 4:e48aee3e8d09 33 union TokenValue uValue;
matis755 4:e48aee3e8d09 34 } Token;
matis755 4:e48aee3e8d09 35
matis755 4:e48aee3e8d09 36
matis755 4:e48aee3e8d09 37 typedef struct Keyword
matis755 4:e48aee3e8d09 38 {
matis755 4:e48aee3e8d09 39 enum KeywordCode eCode;
matis755 4:e48aee3e8d09 40 char cString[MAX_KEYWORD_STRING_LTH + 1];
matis755 4:e48aee3e8d09 41 } Keyword;
matis755 4:e48aee3e8d09 42
matis755 4:e48aee3e8d09 43
matis755 4:e48aee3e8d09 44 class Decoder {
matis755 4:e48aee3e8d09 45 private:
matis755 4:e48aee3e8d09 46 struct Token asToken[MAX_TOKEN_NR];
matis755 4:e48aee3e8d09 47 unsigned char ucTokenCnt;
matis755 4:e48aee3e8d09 48 void ReplaceCharactersInString(char pcString[],char cOldChar,char cNewChar);
matis755 4:e48aee3e8d09 49 enum Result eHexStringToUInt(char pcStr[],unsigned int *puiValue);
matis755 4:e48aee3e8d09 50 unsigned char ucFindTokensInString(char *pcString);
matis755 4:e48aee3e8d09 51 enum Result eStringToKeyword (char pcStr[],enum KeywordCode *peKeywordCode);
matis755 4:e48aee3e8d09 52 void DecodeTokens(unsigned char ucTokenCnt);
matis755 4:e48aee3e8d09 53 public:
matis755 4:e48aee3e8d09 54 void DecodeMsg(char *pcString);
matis755 4:e48aee3e8d09 55 enum TokenType eGetTokenType(unsigned char ucIdx);
matis755 4:e48aee3e8d09 56 enum KeywordCode eGetKeyword(unsigned char ucIdx);
matis755 5:3c19c3ae6286 57 unsigned int uiGetNumber(unsigned char ucIdx);
matis755 4:e48aee3e8d09 58 unsigned char GetTokenCnt(void);
matis755 4:e48aee3e8d09 59 };
matis755 4:e48aee3e8d09 60
matis755 4:e48aee3e8d09 61
matis755 4:e48aee3e8d09 62 #endif