mbed2 zad 5b
Dependencies: LCD_DISCO_F429ZI mbed BSP_DISCO_F429ZI
Revision 5:cafab5a4d1c9, committed 2020-06-09
- Comitter:
- krzysiek99
- Date:
- Tue Jun 09 12:30:01 2020 +0000
- Parent:
- 4:7855d3ab4c15
- Commit message:
- mbed2
Changed in this revision
diff -r 7855d3ab4c15 -r cafab5a4d1c9 Dekodowanie/Tokeny/Tokeny.cpp --- a/Dekodowanie/Tokeny/Tokeny.cpp Mon Jun 08 21:49:36 2020 +0000 +++ b/Dekodowanie/Tokeny/Tokeny.cpp Tue Jun 09 12:30:01 2020 +0000 @@ -6,7 +6,7 @@ extern struct Token asToken[MAX_TOKEN_NR]; extern struct Keyword asKeywordList[MAX_KEYWORD_NR]; - +/* void ReplaceCharactersInString(char pcString[], char cOldChar, char cNewChar) { char *pcStringCharacters = pcString; @@ -18,26 +18,26 @@ } } + enum Result eHexStringToUInt(char pcStr[], unsigned int *puiValue) { - char *pcEnd; unsigned char ucCharCounter; - if((strncmp(pcStr, "0x", 2) != 0) ||(strlen(pcStr)) != 6) + if((strncmp(pcStr, "0x", 2) != 0) || (strlen(pcStr)) != 6) { return ERROR; } - for(ucCharCounter = 2; pcStr[ucCharCounter] != NULL; ucCharCounter++) + for(ucCharCounter = 2; ucCharCounter < 6; ucCharCounter++) { if((strncmp(pcStr+ucCharCounter, "0", 1) < 0) || (strncmp(pcStr+ucCharCounter, "F", 1) > 0) || ((strncmp(pcStr+ucCharCounter, "9", 1) > 0) && (strncmp(pcStr+ucCharCounter, "A", 1) < 0))) { return ERROR; } } - *puiValue = strtol(pcStr, &pcEnd, 0); + *puiValue = strtol(pcStr, NULL, 0); return OK; } - +*/ unsigned char ucFindTokensInString (char *pcString) { char *pcTokenStart = pcString; @@ -71,6 +71,7 @@ void DecodeTokens(void) { + unsigned int uiTokenNumber; unsigned char ucTokenListCounter; struct Token *TokenValue; @@ -81,9 +82,11 @@ { TokenValue->eType = KEYWORD; } - else if( eHexStringToUInt(TokenValue->uValue.pcString, &TokenValue->uValue.uiNumber) == OK ) + else if (sscanf(asToken[ucTokenListCounter].uValue.pcString, "%4x", &uiTokenNumber) == 1) + //else if( eHexStringToUInt(TokenValue->uValue.pcString, &TokenValue->uValue.uiNumber) == OK ) { TokenValue->eType = NUMBER; + TokenValue->uValue.uiNumber = uiTokenNumber; } else {
diff -r 7855d3ab4c15 -r cafab5a4d1c9 Dekodowanie/Tokeny/Tokeny.h --- a/Dekodowanie/Tokeny/Tokeny.h Mon Jun 08 21:49:36 2020 +0000 +++ b/Dekodowanie/Tokeny/Tokeny.h Tue Jun 09 12:30:01 2020 +0000 @@ -3,6 +3,7 @@ #include <string.h> #include <cstring> #include <stdlib.h> + #include <stdio.h> #define MAX_TOKEN_NR 2 //maksymalna dopuszczalna ilosc tokenów #define MAX_KEYWORD_STRING_LTH 13 // maksymalna dlugosc komendy #define MAX_KEYWORD_NR 4
diff -r 7855d3ab4c15 -r cafab5a4d1c9 Funkcje_UART/FunkcjeUART.cpp --- a/Funkcje_UART/FunkcjeUART.cpp Mon Jun 08 21:49:36 2020 +0000 +++ b/Funkcje_UART/FunkcjeUART.cpp Tue Jun 09 12:30:01 2020 +0000 @@ -37,6 +37,8 @@ { bResult = 0; *(--pString) = 0; + // pString--; + // *pString = 0; break; } }