Treehouse Mbed Team / Mbed 2 deprecated APS_DCM1SL2

Dependencies:   mbed

Revision:
36:849c22bd60b0
Parent:
35:ec224d706f7c
Child:
37:1cbd51e24610
--- a/src/command.cpp	Tue Oct 22 20:59:27 2019 +0000
+++ b/src/command.cpp	Sat Oct 26 21:10:13 2019 +0000
@@ -566,7 +566,44 @@
        tok = strtok(commandStringBuf, "=");
        strcpy(commandString, tok);
        tok = strtok(NULL, "=");
-       commandData = atof(tok);
+       if (tok[0] == '0' && tok[1] == 'x')
+       {
+           long long decimal;
+           int i = 0,val,len,pow,power;
+           decimal = 0;
+           len = strlen(tok);
+           len = len - 3;
+           for(i=2; tok[i]!='\0'; i++)
+           {
+               /* Find the decimal representation of tok[i] */
+               if(tok[i]>='0' && tok[i]<='9')
+               {
+                    val = tok[i] - 48;
+                }
+                else if(tok[i]>='a' && tok[i]<='f')
+                {
+                    val = tok[i] - 97 + 10;
+                }
+                else if(tok[i]>='A' && tok[i]<='F')
+                {
+                    val = tok[i] - 65 + 10;
+                }
+                //decimal += val * pow(16, len);
+                pow = len;
+                power = 1;
+                while (pow > 0)
+                {
+                    power = power * 16;
+                    pow--;
+                }
+                decimal += val * power;
+                len--;
+            }
+            commandData = decimal;
+        }
+        else{
+            commandData = atof(tok);
+        }
     }
     else{
         strcpy(commandString, commandStringBuf);