fs and ftg working. bent forward not working

Fork of dataComm by Bradley Perry

dataComm.h

Committer:
mzling
Date:
2015-03-20
Revision:
0:f0dc2775ec68
Child:
1:ad39c297a768

File content as of revision 0:f0dc2775ec68:

#ifndef DATACOMM_H
#define DATACOMM_H

#include <map>
#include <string>

#include "mbed.h"
//#include "MODSERIAL.h"
/**
* @file dataComm.h
* @brief This header file describes dataComm, an object that receives and processes messages through Bluetooth.
* @author Michael Ling
* @date 2/4/2015
*/

class dataComm
{
public:
    dataComm();

    bool parity(short c);
    char* get_checksum(char* b, int len);
    //void send_error(char errCode);
    //void setCharge(short level);
    void set_values(std::map<string, short> newValues);
    
    //void send(char* cmd);
    void send_values(char* paramList);
    void send_read_only_values();
    bool msg_check(char* msg, int len);
    //void process_read_only(char* message, int len);
    //void process_read(char* message, int len);
    //void process_write(short* message, int len);
    void process_write(short int *message, int len);
    char *convert_to_char_array(short int *message, int len);
    //void process(char* message, int len);
    //void attachment();
    int main();
    short generic_get(string var);
    void generic_set(string var, short newval);
    
private:
    //MODSERIAL _rn42; // serial object to read data coming in
    //Map containing values of Exo parameters
    std::map<std::string, short> _paramMap;
    //Maps parameter indices to param names
    std::string _indexMap[50];
    //Last received MSG
    char _msg[50];
    //Value of Exo parameters, stored locally
    // _localValues[50];
    char _curMsg[50];
    int _numVars;
    //Last sent command
    char _lastCmd[50];
    int _failures;
    //Readonly Parameters
    int _numReadOnlyParams;
    short _readOnlyParams[12];
    //Indices where an escape char. is needed
    int _escapeNeeded[9];
    int _escapesNeeded;
    int _len;
    int _counter;
    bool _inMsg;
    int _data;
    
    //START/END bytes, parameter indices
    static const char START = 0xff;
    static const char END = 0xfe;
    static const char KPSTANCE_IND = 0x0;
    static const char KPSWING_IND = 0x1;
    static const char KPSTAND_IND = 0x2;
    static const char KPSIT_IND = 0x3;
    static const char KPUP_IND = 0x4;
    static const char KPDOWN_IND = 0x5;
    static const char KDSTANCE_IND = 0x6;
    static const char KDSWING_IND = 0x7;
    static const char KDSTAND_IND = 0x8;
    static const char KDSIT_IND = 0x9;
    static const char KDUP_IND = 0xa;
    static const char KDDOWN_IND = 0xb;
    static const char STAND_IND = 0xc;
    static const char SIT_IND = 0xd;
    static const char BENT_IND = 0xe;
    static const char FORWARD_IND = 0xf;
    static const char REAR_IND = 0x10;
    static const char IMU_IND = 0x11;
    static const char RETRACT_IND = 0x12;
    static const char EXTEND_IND = 0x13;
    static const char LOCK_IND = 0x14;
    static const char RATE_IND = 0x15;
    static const char SUASST_IND = 0x16;
    static const char SUTIME_IND = 0x17;
    static const char SDASST_IND = 0x18;
    static const char SDTIME_IND = 0x19;
    static const char WALK_IND = 0x1a;
    
    //Indicates a readonly request
    static const char READONLY_IND = 0x1f;
    
    //Error codes
    static const char START_ERR = 1;
    static const char END_ERR = 2;
    static const char PARITY_ERR = 3;
    static const char CHECKSUM_ERR = 4;
    static const char VAR_ERR = 5;
    static const char DATA_ERR =  6;
    static const char RW_ERR = 7;
    
};
#endif