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.

Files at this revision

API Documentation at this revision

Comitter:
julmbed
Date:
Tue Aug 26 08:20:02 2014 +0000
Parent:
11:a3af7a5e03d2
Child:
13:e1ba5bf9e51f
Commit message:
using new and variable number of variables

Changed in this revision

VarStore.cpp Show annotated file Show diff for this revision Revisions of this file
VarStore.h Show annotated file Show diff for this revision Revisions of this file
--- a/VarStore.cpp	Tue Aug 26 07:17:39 2014 +0000
+++ b/VarStore.cpp	Tue Aug 26 08:20:02 2014 +0000
@@ -15,10 +15,13 @@
 *
 *
 ********************************/
-VarStore::VarStore(     RawSerial *ser)
+VarStore::VarStore(     RawSerial *ser, int sz)
 {
     VarCounter=0;
     this->pc=ser;
+    this->sz=sz;
+    //Store=(VarItem *) malloc( sizeof(VarItem)*sz);
+    Store=new VarItem[sz];
 }
 
 /*******************************
@@ -70,16 +73,20 @@
 
 int VarStore::Load(char *Name, void *VarPtr,VarTypes VarType, int Size )
 {
-
+    pc->puts("Entro en Load \n");
     if(GetVar(Name) ==NULL) {
-        if(VarCounter < SZ) {
+        pc->puts("variable no esta \n");
+        if(VarCounter < sz) {
+            pc->puts("incorporo variable a Store \n");
             Store[VarCounter].SetVar(VarType,VarPtr);
             Store[VarCounter].SetVarName(Name);
             Store[VarCounter].SetVarArraySize(Size);
             VarCounter++;
-            return 0;
+            pc->puts("salgo por NULL \n");
+            return NULL;
         }
     }
+    pc->puts("salgo por error \n");
     return ERR;
 }
 
@@ -90,7 +97,7 @@
 
 VarItem *VarStore::GetVar(char *Name)
 {
-    for (int i=0; i<SZ; i++)
+    for (int i=0; i<sz; i++)
         if((strcmp(Name,Store[i].GetVarName()))==0)
             return &Store[i];
 
--- a/VarStore.h	Tue Aug 26 07:17:39 2014 +0000
+++ b/VarStore.h	Tue Aug 26 08:20:02 2014 +0000
@@ -21,7 +21,7 @@
     *Constructor
     ********************************/
 
-    VarStore(   RawSerial *ser);
+    VarStore(   RawSerial *ser, int sz);
     /*******************************
     *
     *Destructor
@@ -93,10 +93,11 @@
     *
     *
     ********************************/
-    VarItem Store[SZ];
+    VarItem *Store;
+    int sz;         // number of varibales to store / array size
     int VarCounter;
-        RawSerial  *pc;
-    
+    RawSerial  *pc;
+
     static VarStore *MyThis;   // used by the workers reading the terminal
 
 };