i2c working with old hk

Dependencies:   mbed-rtos mbed

Fork of BAE_vr2_1_1 by green rosh

Revision:
14:ef6be8ac6569
Parent:
13:1b37d98840d3
--- a/main.cpp	Wed Dec 17 05:25:04 2014 +0000
+++ b/main.cpp	Wed Dec 17 06:06:59 2014 +0000
@@ -40,7 +40,7 @@
 
 typedef struct
 {
-    char data[21];          // To avoid dynamic memory allocation
+    char data[18];          // To avoid dynamic memory allocation
     int length;
 }i2c_data;
 
@@ -56,19 +56,19 @@
 //TASK 2 : HK
 //--------------------------------------------------------------------------------------------------------------------------------------------------
 
-char hk_data[21];
-extern SensorDataQuantised SensorQuantised;
+char hk_data[18];
+extern SensorData Sensor;
 void t_hk_acq(void const *args)
 {
     
     while(1)
     {
         Thread::signal_wait(0x2);
-        SensorQuantised.power_mode='0';
+        Sensor.power_mode='0';
         printf("\nTHIS IS HK    %f\n",t1.read());
         t.start();
         FAULTS();
-        POWER(SensorQuantised.power_mode);                                                   //The power mode algorithm is yet to be obtained
+        POWER(Sensor.power_mode);                                                   //The power mode algorithm is yet to be obtained
         FUNC_HK_MAIN();                                                             //Collecting HK data
         //thread_2.signal_set(0x4);
         //FUNC_I2C_SLAVE_MAIN(24);    
@@ -204,7 +204,7 @@
     }
 }*/
 
-extern SensorDataQuantised SensorQuantised;
+extern SensorData Sensor;
 
 
 /*void T_FAULT(void const *args)
@@ -303,7 +303,7 @@
             printf("\ndone\n\r");
 
 }
-char data_send[21],data_receive[21];
+char data_send[18],data_receive[18];
 void T_I2C_BAE()
 {
     //char data_send,data_receive;
@@ -316,10 +316,10 @@
         if(i2c_status == 0 && reset !=1)
         {
             
-            FUNC_I2C_WRITE2CDMS(data_receive,21);
+            FUNC_I2C_WRITE2CDMS(data_receive,18);
             i2c_data * i2c_data_r = i2c_data_receive.alloc();
             strcpy(i2c_data_r->data,data_receive);
-            i2c_data_r->length = 21;
+            i2c_data_r->length = 18;
             i2c_data_receive.put(i2c_data_r);
             printf("\n Data received from CDMS is %s \n\r",data_receive);
             i2c_data_receive.free(i2c_data_r);                              // This has to be done from a differen thread
@@ -332,7 +332,7 @@
             {
                 i2c_data *i2c_data_s = (i2c_data*)evt.value.p;
                 strcpy(data_send,i2c_data_s -> data);
-                FUNC_I2C_WRITE2CDMS(data_send,21);
+                FUNC_I2C_WRITE2CDMS(data_send,18);
                 printf("\nData sent to CDMS is %s\n\r",data_send);
                 i2c_data_send.free(i2c_data_s);
                 i2c_status = 0;
@@ -360,20 +360,21 @@
 
 
 
-char fdata[8] = {SensorQuantised.Vcell_soc,SensorQuantised.alerts,SensorQuantised.crate,SensorQuantised.BatteryTemperature,SensorQuantised.faultpoll,SensorQuantised.faultir, SensorQuantised.power_mode};
 
 void ir2master()
 {
         
-        //char data[21];
+        //char data[18];
         //strcpy(data,"sakthi ");
         //strcat(data,"priya");
-        strcpy(hk_data,SensorQuantised.Voltage);
-        strcat(hk_data,SensorQuantised.Temperature);                                                 //Sending to CDMS via I2C
-        strcat(hk_data,SensorQuantised.Current); 
-        strcat(hk_data,SensorQuantised.PanelTemperature);
-        strcat(hk_data,SensorQuantised.AngularSpeed);
-        strcat(hk_data,SensorQuantised.Bnewvalue);
+        strcpy(hk_data,Sensor.Voltage);
+        strcat(hk_data,Sensor.Temperature);                                                 //Sending to CDMS via I2C
+        strcat(hk_data,Sensor.Current); 
+        //strcat(hk_data,SensorQuantised.PanelTemperature);
+        //strcat(hk_data,SensorQuantised.AngularSpeed);
+        //strcat(hk_data,SensorQuantised.Bnewvalue);
+        char fdata[8] = {Sensor.faultpoll,Sensor.faultir,Sensor.power_mode};
+
         /*strcat(hk_data,sfaultpoll);
         strcat(hk_data,sfaultir);
         strcat(hk_data,spower_mode);*/
@@ -385,7 +386,7 @@
         i2c_status=1;
         i2c_data * i2c_data_s = i2c_data_send.alloc();
         strcpy(i2c_data_s->data,hk_data);
-        i2c_data_s->length = 21;
+        i2c_data_s->length = 18;
         i2c_data_send.put(i2c_data_s); 
         data_ready=1;
         //temp = i2c_status;