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:
Mon Aug 25 14:58:42 2014 +0000
Parent:
4:4be2eaf872df
Child:
6:9848fdaf2ad9
Commit message:
antes de meter los cambios de VarStore::MyThis en worker2

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	Mon Aug 25 12:39:23 2014 +0000
+++ b/VarStore.cpp	Mon Aug 25 14:58:42 2014 +0000
@@ -115,9 +115,9 @@
 *
 ********************************/
 
-void VarStore::Worker(void const *args)
+void VarStore::Worker2()
 {
-    VarStore *MyThis=(VarStore *)args;
+    
     char c, *ret=STR_OK;// not NULL to start in no error state
     
     int ci_counter=0;
@@ -155,7 +155,6 @@
         }
 
         if(ret==NULL) {
-            Thread::wait(100);
             MyThis->pc->printf(" error setting/getting var \n");
             ret=STR_OK;
         }
@@ -167,6 +166,22 @@
 *
 *
 ********************************/
+void VarStore::Worker(void const *args)
+{
+
+    VarStore::MyThis=(VarStore *)args;
+
+    VarStore::MyThis->pc->attach(VarStore::Worker2);
+
+    while(1) {
+        Thread::wait(10000);
+    }
+
+}
+/*******************************
+*
+*
+********************************/
 
 char  *VarStore::Do(char *str, VarStore* MyThis)
 {
--- a/VarStore.h	Mon Aug 25 12:39:23 2014 +0000
+++ b/VarStore.h	Mon Aug 25 14:58:42 2014 +0000
@@ -77,6 +77,13 @@
     *
     ********************************/
     char  *Do(char *str, VarStore *MyThis);
+    
+    /*******************************
+    *Para hacer gestión via interrupciones.
+    *
+    ********************************/
+    static void Worker2();
+    
     /*******************************
     *
     *
@@ -84,6 +91,7 @@
     VarItem Store[SZ];
     int VarCounter;
     Serial *pc;
+    static VarStore *MyThis;   // used by the worker reading the terminal
 
 
 };