ACS data acq changed completely. Tested and working. Deals all faults.
Dependencies: FreescaleIAP mbed-rtos mbed
Fork of QM_BAE_review_1 by
Diff: TCTM.cpp
- Revision:
- 8:82250e41da81
- Parent:
- 6:036d08b62785
- Child:
- 9:194afacf7449
diff -r a46a1dee4497 -r 82250e41da81 TCTM.cpp --- a/TCTM.cpp Sat Jan 23 11:35:20 2016 +0000 +++ b/TCTM.cpp Sat Mar 12 12:54:14 2016 +0000 @@ -32,7 +32,7 @@ uint8_t service_type=(tc[2]&0xF0); uint8_t* tm; uint16_t crc16; - + switch(service_type) { @@ -50,9 +50,36 @@ case 0x02: { printf("Read from RAM\r\n"); - switch(tc[3]) + + uint16_t MID = ((uint16_t)tc[3] << 8) | tc[4]; + switch(MID ) { - case 0x01: + case 0x0010: + { + printf("Read MUX DATA\r\n"); + tm[0] = 0x60; + tm[1] = tc[0]; + tm[2] = ACK_CODE; + for(int i=0; i<3; i++) + FCTN_CONVERT_FLOAT(actual_data.Bvalue_actual[i],&tm[4+ (i*4)]); //tm[4] - tm[7] + for(int i=0; i<3; i++) + FCTN_CONVERT_FLOAT(actual_data.AngularSpeed_actual[i],&tm[35+(i*4)]); // + + for(int i=0; i<16; i++) //16*4 = 64 bytes //tm[4] to tm[67] filled + FCTN_CONVERT_FLOAT(actual_data.voltage_actual[i], &tm[4+(i*4)]); + for(int i=0; i<12; i++) //12*4 = 48 //tm[68] to tm[115] filled + FCTN_CONVERT_FLOAT(actual_data.current_actual[i],&tm[68 + (i*4)]); + for (int i=116; i<132;i++) + { + tm[i] = 0x00; + } + crc16 = CRC::crc16_gen(tm,132); + tm[132] = (uint8_t)((crc16&0xFF00)>>8); + tm[133] = (uint8_t)(crc16&0x00FF); + return tm; + } + //......................... + case 0x0010: { printf("Read MUX DATA\r\n"); tm[0] = 0x60; @@ -71,12 +98,18 @@ tm[133] = (uint8_t)(crc16&0x00FF); return tm; } - case 0x02: + //.......................................... + case 0x2: { printf("Read HK\r\n"); tm[0] = 0x60; tm[1] = tc[0]; tm[2] = ACK_CODE; + for(int i=0; i<3; i++) + FCTN_CONVERT_FLOAT(actual_data.Bvalue_actual[i],&tm[4+ (i*4)]); //tm[4] - tm[7] + for(int i=0; i<3; i++) + FCTN_CONVERT_FLOAT(actual_data.AngularSpeed_actual[i],&tm[35+(i*4)]); // + FCTN_CONVERT_FLOAT(actual_data.Batt_temp_actual[0],&tm[4]); //tm[4]-tm[7] FCTN_CONVERT_FLOAT(actual_data.Batt_temp_actual[1],&tm[8]); //tm[8]- tm[11] for(int i=0; i<4; i++) @@ -85,10 +118,6 @@ tm[32] = (uint8_t)actual_data.power_mode; tm[33] = actual_data.faultPoll_status; tm[34] = actual_data.faultIr_status; - for(int i=0; i<3; i++) - FCTN_CONVERT_FLOAT(actual_data.AngularSpeed_actual[i],&tm[35+(i*4)]); //35 -46 - for(int i=0; i<3; i++) - FCTN_CONVERT_FLOAT(actual_data.Bvalue_actual[i],&tm[47+(i*4)]); //47 -58 FCTN_CONVERT_FLOAT(actual_data.Batt_voltage_actual,&tm[59]); //59 - 62 for (int i=63; i<132;i++) { @@ -100,7 +129,7 @@ return tm; } - case 0x03: + case 0x3: { printf("Read min max data"); tm[0] = 0x60; @@ -152,7 +181,7 @@ tm[133] = (uint8_t)(crc16&0x00FF); return tm; } - case 0x04: + case 0x4: { printf("Read status"); tm[0] = 0x60;