library to modify and read program variable in runtime from a serial console. You can reset as well the mbed from the console without pushing buttons. Handy for debugging from the online compiler as you can change the behavior of the program without need to recompile each time.

Revision:
9:d081aa4e4418
Parent:
8:934ec53fe2c0
Child:
13:e1ba5bf9e51f
--- a/VarItems.cpp	Mon Aug 25 19:54:12 2014 +0000
+++ b/VarItems.cpp	Mon Aug 25 20:44:39 2014 +0000
@@ -4,9 +4,9 @@
 #include <stdio.h>
 #include "mbed.h"
 
-extern Serial pc;
+extern RawSerial pc;
 
-#define DMP_SZ 100
+#define DMP_SZ 132
 
 
 VarItem::VarItem()
@@ -87,20 +87,13 @@
 
 char *VarItem::Dump()
 {
-pc.puts(" 0 \n");
-    static char *StrDump=NULL;
-
-    unsigned int DumpSize=0;
+    static char StrDump[DMP_SZ];
+    unsigned int DumpSize=DMP_SZ;
     unsigned int  DumpCounter=0, ArrayCounter=0;;
     char Tmp[16];
-
-    if(StrDump!=NULL) free(StrDump);
-
-    DumpSize=DMP_SZ;
-    StrDump=(char *)malloc(DumpSize);
+    
     memset(StrDump,0,DMP_SZ);
 
-pc.puts(" 1 \n");
     do {
         switch(VarType) {
             case T_int:
@@ -110,16 +103,17 @@
                 sprintf(Tmp,"%f,",*(ValFloat+ArrayCounter));
                 break;
         };
-pc.puts(" 2 \n");
         if(DumpCounter+strlen(Tmp) >= DumpSize) {
+            /*
             char *d;
             DumpSize = DumpCounter+DMP_SZ;
             d=(char *)malloc(DumpCounter+DMP_SZ);
             strcpy(d,StrDump);
             free(StrDump);
             StrDump=d;
+            */
+            break;
         }
-pc.puts(" 3 \n");
         strcat(StrDump+DumpCounter,Tmp);
         DumpCounter+=strlen(Tmp);
         ArrayCounter++;