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:
- 15:e09aaaccf134
- Parent:
- 14:a9588f443f1a
- Child:
- 16:cc77770d787f
diff -r a9588f443f1a -r e09aaaccf134 TCTM.cpp --- a/TCTM.cpp Thu Apr 14 09:34:06 2016 +0000 +++ b/TCTM.cpp Tue Apr 19 21:27:07 2016 +0000 @@ -83,7 +83,8 @@ { // tm1[0] = 1; uint8_t service_type=(tc[2]&0xF0); - + /*chaged*/ + uint8_t* tm; // without it some identifier error uint16_t crc16; @@ -99,17 +100,64 @@ case 0x01: { printf("Read from Flash\r\n"); + uint16_t jj; + uint16_t MID = ((uint16_t)tc[3] << 8) | tc[4]; + switch(MID) + {case 0x1100:jj=0x00;// using uint16_t as jj typesimilarly used in FCTN_CDMS_WR_FLASH + break; + case 0x0100:jj=0x01; + break; + case 0x0101:jj=0x02; + break; + case 0x0102:jj=0x03; + break; + case 0x0107:jj=0x04; + break; + case 0x0103:jj=0x05; + break; + case 0x0104:jj=0x05; + break; + case 0x0105:jj=0x06; + break; + case 0x0106:jj=0x07; + break; + } + /*pointer....!!!!*/ + uint32_t FLASH_TEMP = FCTN_CDMS_RD_FLASH(jj); + + tm[0] = 0x60; + tm[1] = tc[0]; + tm[2] = ACK_CODE; + for(int i=0; i<8*4; i+=4) + { + tm[4+i] =(uint8_t )(((FLASH_TEMP)>>24)&0xFF); + tm[5+i] =(uint8_t ) (((FLASH_TEMP)>>16)&0xFF); + tm[6+i] =(uint8_t ) (((FLASH_TEMP)>>8)&0xFF); + tm[7+i] =(uint8_t ) ((FLASH_TEMP) & 0xFF); + + } + + + for (int i=4+8*4; 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); + break; } case 0x02: { + printf("Read from RAM\r\n"); uint16_t MID = ((uint16_t)tc[3] << 8) | tc[4]; switch(MID) { case 0x0001: { - printf("Read from RAM\r\n"); + printf("\nRead from MID 0001 hk\n"); /*taking some varible till we find some thing more useful*/ //uint8_t ref_val=0x01; @@ -182,10 +230,34 @@ telemetry[24] = P_EPS_MAIN_COUNTER>>8; telemetry[25] = P_EPS_MAIN_COUNTER; + //actual_data.AngularSpeed_actual[0]=5.32498; for(int i=0; i<3; i++) - FCTN_CONVERT_FLOAT(actual_data.Bvalue_actual[i],&telemetry[26+ (i*4)]); + FCTN_CONVERT_FLOAT((float)actual_data.Bvalue_actual[i],&telemetry[26+ (i*4)]); for(int i=0; i<3; i++) - FCTN_CONVERT_FLOAT(actual_data.AngularSpeed_actual[i],&telemetry[38+(i*4)]); + FCTN_CONVERT_FLOAT((float)actual_data.AngularSpeed_actual[i],&telemetry[38+(i*4)]); + + //printf("\n\rthe value is 38\t %x\n",telemetry[38]); + //printf("\n\rthe value is 39\t%x\n",telemetry[39]); + //printf("\n\rthe value is 40\t%x\n",telemetry[40]); + //printf("\n\rthe value is 41\t%x\n",telemetry[41]); + //printf("\n\rthe value true\t%f\n",actual_data.AngularSpeed_actual[0]); + + + //uint32_t input_stage1=0x00000000; + //uint8_t output1[4]; + //output1[0]=(uint32_t)(telemetry[38]); + //output1[1]=(uint32_t)(telemetry[39]); + //output1[2]=(uint32_t)(telemetry[40]); + //output1[3]=(uint32_t)(telemetry[41]); + + //input_stage1=output[3]+(output[2]*(0x100))+(output[1]*(0x10000))+(output[0]*(0x1000000)); + //input_stage1=(output1[0]<<24) | (output1[1]<<16) | (output1[2]<<8) | (output1[3]); + + + //assert(sizeof(float) == sizeof(uint32_t)); + //float* temp1 = reinterpret_cast<float*>(&input_stage1); + + //printf("\n\r the value is: %f \n",*temp1); //FAULT_FLAG(); telemetry[50] = actual_data.faultIr_status; @@ -242,6 +314,7 @@ } case 0x0002: { + printf("\r\n"); telemetry[0] = 0x60; telemetry[1] = tc[0]; telemetry[2] = ACK_CODE; @@ -312,7 +385,87 @@ } case 0x05: { - printf("Write on Flash\r\n"); + printf("\nRead from MID 0001 min max\n"); + /*changed*/ + printf("\n\rwrite on flash\n"); + uint32_t FLASH_DATA[8]; + + uint16_t MID = ((uint16_t)tc[3] << 8) | tc[4]; + switch(MID ) + { + + case 0x0100: + { + FLASH_DATA[0] = (((uint32_t)tc[5] << 24) | ((uint32_t)tc[6] << 16) | ((uint32_t)tc[7] << 8) | (uint32_t)tc[6]); + FCTN_CDMS_WR_FLASH(0x00,FLASH_DATA[0]); + break; + } + case 0x0101: + { + FLASH_DATA[1] = (((uint32_t)tc[5] << 24) | ((uint32_t)tc[6] << 16) | ((uint32_t)tc[7] << 8) | (uint32_t)tc[6]); + FCTN_CDMS_WR_FLASH(0x01,FLASH_DATA[1]); + break; + } + + case 0x0102: + { + FLASH_DATA[2] = (((uint32_t)tc[5] << 24) | ((uint32_t)tc[6] << 16) | ((uint32_t)tc[7] << 8) | (uint32_t)tc[6]); + FCTN_CDMS_WR_FLASH(0x02,FLASH_DATA[2]); + break; + } + + case 0x0103: + { + FLASH_DATA[3] = (((uint32_t)tc[5] << 24) | ((uint32_t)tc[6] << 16) | ((uint32_t)tc[7] << 8) | (uint32_t)tc[6]); + FCTN_CDMS_WR_FLASH(0x03,FLASH_DATA[3]); + break; + } + case 0x0104: + { + FLASH_DATA[4] = (((uint32_t)tc[5] << 24) | ((uint32_t)tc[6] << 16) | ((uint32_t)tc[7] << 8) | (uint32_t)tc[6]); + FCTN_CDMS_WR_FLASH(0x04,FLASH_DATA[4]); + break; + } + + case 0x0105: + { + FLASH_DATA[5] = (((uint32_t)tc[5] << 24) | ((uint32_t)tc[6] << 16) | ((uint32_t)tc[7] << 8) | (uint32_t)tc[6]); + FCTN_CDMS_WR_FLASH(0x05,FLASH_DATA[5]); + break; + } + case 0x0106: + { + FLASH_DATA[6] = (((uint32_t)tc[5] << 24) | ((uint32_t)tc[6] << 16) | ((uint32_t)tc[7] << 8) | (uint32_t)tc[6]); + FCTN_CDMS_WR_FLASH(0x06,FLASH_DATA[6]); + break; + } + + case 0x0107: + { + FLASH_DATA[7] = (((uint32_t)tc[5] << 24) | ((uint32_t)tc[6] << 16) | ((uint32_t)tc[7] << 8) | (uint32_t)tc[6]); + FCTN_CDMS_WR_FLASH(0x07,FLASH_DATA[7]); + break; + } + + default: + { + printf("Invalid MMS\r\n"); + } + } + + + for (int i=4; 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); + tm[0] = 0x60; + tm[1] = tc[0]; + tm[2] = ACK_CODE; + + printf("Written on Flash\r\n"); break; } default: @@ -1070,6 +1223,7 @@ // Convert float to 4 uint8_t + void FCTN_CONVERT_FLOAT(float input, uint8_t output[4]) { assert(sizeof(float) == sizeof(uint32_t)); @@ -1077,13 +1231,21 @@ //float* output1 = reinterpret_cast<float*>(temp); - printf("\n\r %f ", input); - std::cout << "\n\r uint32"<<*temp << std::endl; + //printf("\n\r %f ", input); + //std::cout << "\n\r uint32"<<*temp << std::endl; output[0] =(uint8_t )(((*temp)>>24)&0xFF); - output[2] =(uint8_t ) (((*temp)>>16)&0xFF); - output[1] =(uint8_t ) (((*temp)>>8)&0xFF); - output[3] =(uint8_t ) ((*temp) & 0xFF); // verify the logic + output[1] =(uint8_t ) (((*temp)>>16)&0xFF); + output[2] =(uint8_t ) (((*temp)>>8)&0xFF); + output[3] =(uint8_t ) ((*temp) & 0xFF); // verify the logic + + printf("\n\rthe values generated are\n"); + /*printf("\n\r%x\n",output[0]); + printf("\n\r%x\n",output[1]); + printf("\n\r%x\n",output[2]); + printf("\n\r%x\n",output[3]); + to check the values generated + */ //printf("\n\r inside %d %d %d %d", output[3],output[2],output[1],output[0]); //std:: cout << "\n\r uint8 inside " << output[3] << '\t' << output[2] << '\t' << output[1] << '\t' << output[0] <<std::endl; } \ No newline at end of file