decode hk data

Dependencies:   mbed-rtos mbed

Fork of CDMS_tc0 by sakthi priya amirtharaj

Files at this revision

API Documentation at this revision

Comitter:
sakthipriya
Date:
Sat Dec 20 06:23:00 2014 +0000
Parent:
1:24c54d213671
Commit message:
decode hk data

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r 24c54d213671 -r c75bb488d17c main.cpp
--- a/main.cpp	Sat Dec 20 06:05:33 2014 +0000
+++ b/main.cpp	Sat Dec 20 06:23:00 2014 +0000
@@ -74,6 +74,61 @@
             interrupt=0;
             printf("\n blahblah\n\r");
 }
+
+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)
 {
@@ -89,7 +144,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);
     }
 }