a

Dependencies:   LCD_DISCO_F429ZI mbed BSP_DISCO_F429ZI

Revision:
6:06ff453bb16e
Parent:
5:3c19c3ae6286
--- a/decoder.cpp	Fri May 22 07:21:44 2020 +0000
+++ b/decoder.cpp	Fri May 22 07:30:59 2020 +0000
@@ -19,29 +19,7 @@
         if(pcString[ucCharCounter] == cOldChar) pcString[ucCharCounter] = cNewChar;
     }
 }
-
-
-
-enum Result Decoder::eHexStringToUInt(char pcStr[],unsigned int *puiValue){
-  
-    unsigned char ucCharCounter;
-  
-    if((pcStr[0] != '0') | (pcStr[1] != 'x') | (pcStr[2] == '\0'))
-        return NOK;
-    *puiValue = 0;
-    for(ucCharCounter=2;ucCharCounter<7;ucCharCounter++){
-        if(pcStr[ucCharCounter] == '\0') 
-            return OK;
-      *puiValue = *puiValue << 4;
-        if(pcStr[ucCharCounter] >= 'A') 
-            *puiValue = *puiValue | (pcStr[ucCharCounter] - 'A' + 10); 
-        else 
-            *puiValue = *puiValue | (pcStr[ucCharCounter] - '0');
-    }
-    return OK;
-}
-
-    
+ 
 unsigned char Decoder::ucFindTokensInString(char *pcString){
   
     unsigned char ucTokenPointer;
@@ -98,7 +76,10 @@
     for(ucTokenCounter=0;ucTokenCounter<ucTokenCnt;ucTokenCounter++){
         tValue = &asToken[ucTokenCounter];
         if (eStringToKeyword(tValue->uValue.pcString,&tValue->uValue.eKeyword) == OK) tValue->eType = KEYWORD;
-        else if (eHexStringToUInt(tValue->uValue.pcString,&tValue->uValue.uiNumber) == OK) tValue->eType = NUMBER;
+        else if ((int)strtol(tValue->uValue.pcString, NULL, 0)) {
+            tValue->uValue.uiNumber = (int)strtol(tValue->uValue.pcString, NULL, 0);
+            tValue->eType = NUMBER;
+        }
         else tValue->eType = STRING;
     }
 }