http://developer.mbed.org/users/sakthipriya/code/BAE_honeycomb1/
Fork of CDMS_tc by
Revision 1:60e6283e6532, committed 2014-12-18
- Comitter:
- sakthipriya
- Date:
- Thu Dec 18 12:22:14 2014 +0000
- Parent:
- 0:252ce694a71e
- Commit message:
- http://developer.mbed.org/users/sakthipriya/code/BAE_honeycomb1/
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Wed Dec 17 12:49:58 2014 +0000 +++ b/main.cpp Thu Dec 18 12:22:14 2014 +0000 @@ -6,6 +6,7 @@ Serial pc (USBTX,USBRX); DigitalOut interrupt(D9); InterruptIn data_ready(D10); +//DigitalOut mreset(D8); int reset; @@ -73,6 +74,60 @@ //delete data; interrupt=0; } + +typedef struct { + char Voltage[9]; + char Current[5]; + char Temperature[2]; + char PanelTemperature[3];//read by the 4 thermistors on solar panels + char BatteryTemperature; //to be populated + char faultpoll; //polled faults + char faultir; //interrupted faults + char power_mode; //power modes + char AngularSpeed[3]; + char Bnewvalue[3]; + + //float magnetometer,gyro=>to be addes +} hk_data; +hk_data decode_data; + +void TC_DECODE(char *data_hk) //getting the structure back from hk data sent by bae +{ + for(int i=0;i<=7;i++) + { + decode_data.Voltage[i] = data_hk[i]; + decode_data.Voltage[8] = '\0'; + } + for(int i=0;i<=3;i++) + { + decode_data.Current[i] = data_hk[8+i]; + decode_data.Current[4] = '\0'; + } + decode_data.Temperature[0] = data_hk[12]; + decode_data.Temperature[1] = '\0'; + for(int i=0;i<=1;i++) + { + decode_data.PanelTemperature[i] = data_hk[13+i]; + decode_data.PanelTemperature[2] = '\0'; + } + decode_data.BatteryTemperature = data_hk[15]; + decode_data.faultpoll = data_hk[16]; + decode_data.faultir = data_hk[17]; + decode_data.power_mode = data_hk[18]; + for(int i=0;i<=1;i++) + { + decode_data.AngularSpeed[i] = data_hk[19+i]; + decode_data.AngularSpeed[2] = '\0'; + } + for(int i=0;i<=1;i++) + { + decode_data.Bnewvalue[i] = data_hk[21+i]; + decode_data.Bnewvalue[2] = '\0'; + } + printf("\n voltage %s\n\r",decode_data.Voltage); + printf("\n current %s\n\r",decode_data.Current); + printf("\n faultpoll %c\n\r",decode_data.faultpoll); +} void T_I2C_MASTER_FSLAVE(void const *args) { @@ -86,6 +141,7 @@ i2c_data_r->length = 25; i2c_data_receive.put(i2c_data_r);*/ printf("\n Data received from slave is %s\n\r",data_receive); + TC_DECODE(data_receive); } } @@ -141,6 +197,8 @@ int main() { + //mreset = 1; + printf("\nblahblah\n"); ptr_t_i2c = new Thread(T_I2C_MASTER_FSLAVE); data_ready.rise(&FUNC_INT); printf("\nstarted master\n");