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.

VarStore.h

Committer:
julmbed
Date:
2014-08-26
Revision:
10:34d368966675
Parent:
8:934ec53fe2c0
Child:
11:a3af7a5e03d2

File content as of revision 10:34d368966675:

#ifndef VARSTORE_H
#define VARSTORE_H

#include "mbed.h"



#include "VarItems.h"

#define SZ 10
#define STR_OK ""

class VarStore
{
    
 
// friend    void Worker2();
public:
    /*******************************
    *
    *Constructor
    ********************************/

    VarStore(   RawSerial *ser);
    /*******************************
    *
    *Destructor
    ********************************/

    virtual ~VarStore();
    /*******************************
    *
    *asigna valor a una variable/array o retorna ERR
    ********************************/

    char * Set(char *Input);

    /*******************************
    *
    *devuelve en un string el contenido de una variable
    ********************************/

    char*  Get(char *Name);

    /*******************************
    *carga en el store una variable
    *
    ********************************/

    int Load(char *Name, void *VarPtr,VarTypes VarType );

    /*******************************
    *
    *carga en el store una variable/array
    ********************************/

    int Load(char *Name, void *VarPtr,VarTypes VarType, int Size );

    /*******************************
    * Proceso que less del un serial para modificar
    * los valores de las variables.
    *
    ********************************/

 //   static    void Worker(void const *args);
 static    void Worker(void const *args);
   

protected:

private:
    /*******************************
    * Busca una variable con nombre name.
    *
    ********************************/

    VarItem *GetVar(char *name);

    /*******************************
    * Llamado por worker para
    * llevar a cabo la acción
    *
    ********************************/
    char  *Do(char *str);
    
    /*******************************
    *Para hacer gestión via interrupciones.
    *
    ********************************/
    static void Worker2();
    
    /*******************************
    *
    *
    ********************************/
    VarItem Store[SZ];
    int VarCounter;
        RawSerial  *pc;
    
    static VarStore *MyThis;   // used by the workers reading the terminal

};

    

#endif // VARSTORE_H