changed to be compatible with struct
Fork of dataComm by
Embed:
(wiki syntax)
Show/hide line numbers
dataComm.h
Go to the documentation of this file.
00001 #ifndef DATACOMM_H 00002 #define DATACOMM_H 00003 00004 #include <map> 00005 #include <string> 00006 00007 #include "mbed.h" 00008 /** 00009 * @file dataComm.h 00010 * @brief This header file describes dataComm, an object that receives and processes messages sent to the controlbed via SPI. 00011 * shares many functions with BluetoothComm on the controlbed 00012 * @author Michael Ling 00013 * @date 2/4/2015 00014 */ 00015 00016 class dataComm 00017 { 00018 public: 00019 dataComm(); 00020 00021 bool parity(short c); 00022 char* get_checksum(char* b, int len); 00023 void set_values(std::map<string, short> newValues); 00024 00025 00026 void send_values(char* paramList); 00027 void send_read_only_values(); 00028 bool msg_check(char* msg, int len); 00029 void process_write(short int *message, int len); 00030 int main(); 00031 short generic_get(string var); 00032 void generic_set(string var, short newval); 00033 00034 private: 00035 00036 //Map containing values of Exo parameters 00037 std::map<std::string, short> _paramMap; 00038 //Maps parameter indices to param names 00039 std::string _indexMap[50]; 00040 //Last received MSG 00041 char _msg[50]; 00042 00043 char _curMsg[50]; 00044 int _numVars; 00045 //Last sent command 00046 char _lastCmd[50]; 00047 int _failures; 00048 //Readonly Parameters 00049 int _numReadOnlyParams; 00050 short _readOnlyParams[12]; 00051 //Indices where an escape char. is needed 00052 int _escapeNeeded[9]; 00053 int _escapesNeeded; 00054 int _len; 00055 int _counter; 00056 bool _inMsg; 00057 int _data; 00058 00059 //START/END bytes, parameter indices 00060 static const char START = 0xff; 00061 static const char END = 0xfe; 00062 static const char KPSTANCE_IND = 0x0; 00063 static const char KPSWING_IND = 0x1; 00064 static const char KPSTAND_IND = 0x2; 00065 static const char KPSIT_IND = 0x3; 00066 static const char KPUP_IND = 0x4; 00067 static const char KPDOWN_IND = 0x5; 00068 static const char KDSTANCE_IND = 0x6; 00069 static const char KDSWING_IND = 0x7; 00070 static const char KDSTAND_IND = 0x8; 00071 static const char KDSIT_IND = 0x9; 00072 static const char KDUP_IND = 0xa; 00073 static const char KDDOWN_IND = 0xb; 00074 static const char STAND_IND = 0xc; 00075 static const char SIT_IND = 0xd; 00076 static const char BENT_IND = 0xe; 00077 static const char FORWARD_IND = 0xf; 00078 static const char REAR_IND = 0x10; 00079 static const char IMU_IND = 0x11; 00080 static const char RETRACT_IND = 0x12; 00081 static const char EXTEND_IND = 0x13; 00082 static const char LOCK_IND = 0x14; 00083 static const char RATE_IND = 0x15; 00084 static const char SUASST_IND = 0x16; 00085 static const char SUTIME_IND = 0x17; 00086 static const char SDASST_IND = 0x18; 00087 static const char SDTIME_IND = 0x19; 00088 static const char WALK_IND = 0x1a; 00089 static const char STEPLEN_IND = 0x1b; 00090 static const char STEPTIME_IND = 0x1c; 00091 static const char HIPFLEX_IND = 0x1d; 00092 static const char PHASESHIFT_IND = 0x1e; 00093 static const char MAXAMP_IND = 0x1f; 00094 static const char STANCESTART_IND = 0x20; 00095 static const char STANCEEND_IND = 0x21; 00096 00097 00098 //MIN and MAX values for the various parameters 00099 static const float MIN_STAND = -15; 00100 static const float MAX_STAND = 15; 00101 static const float MIN_SIT = 70; 00102 static const float MAX_SIT = 110; 00103 static const float MIN_BENT = 90; 00104 static const float MAX_BENT = 140; 00105 static const float MIN_SUASST = -.17; 00106 static const float MAX_SUASST = -.11; 00107 static const float MIN_SDASST = -.03; 00108 static const float MAX_SDASST = -.02; 00109 static const float MIN_SDTIME = 3.2; 00110 static const float MAX_SDTIME = 4.8; 00111 static const float MIN_WALK = 0; 00112 static const float MAX_WALK = 10; 00113 static const float MIN_STEPTIME = 700; 00114 static const float MAX_STEPTIME = 1300; 00115 static const float MIN_STANDUPTIME = 0.5; 00116 static const float MAX_STANDUPTIME = 1.5; 00117 00118 static const float MIN_STEPLEN = -10; 00119 static const float MAX_STEPLEN = 10; 00120 static const float MIN_HIPFLEX = 20; 00121 static const float MAX_HIPFLEX = 40; 00122 static const float MIN_PHASESHIFT = 400; 00123 static const float MAX_PHASESHIFT = 600; 00124 00125 //Indicates a readonly request 00126 static const char READONLY_IND = 0x3f; 00127 00128 //Error codes 00129 static const char START_ERR = 1; 00130 static const char END_ERR = 2; 00131 static const char PARITY_ERR = 3; 00132 static const char CHECKSUM_ERR = 4; 00133 static const char VAR_ERR = 5; 00134 static const char DATA_ERR = 6; 00135 static const char RW_ERR = 7; 00136 00137 }; 00138 #endif
Generated on Wed Jul 13 2022 15:23:41 by
1.7.2
