To fix the hang problem
Dependencies: FreescaleIAP SimpleDMA mbed-rtos mbed
Fork of CDMS_CODE by
Diff: CDMS_HK.h
- Revision:
- 230:3d52da8826d3
- Parent:
- 229:42624b9a08b4
--- a/CDMS_HK.h Tue Jul 05 09:35:50 2016 +0000 +++ b/CDMS_HK.h Wed Jul 06 07:24:28 2016 +0000 @@ -27,7 +27,7 @@ { gPC.printf("Entering HK thread"); unsigned char CDMS_HK_FRAME[134] = {0}; - char BAE_HK[128] = {0}; + char BAE_HK[134] = {0}; uint8_t convoluted_CDMS_HK[270]; uint8_t interleave_CDMS_HK[288]; uint8_t CDMS_HEALTH_FINAL[512] = {0}; @@ -92,38 +92,45 @@ CDMS_HEALTH_FINAL[i] = interleave_CDMS_HK[i]; SD_WRITE(CDMS_HEALTH_FINAL,FSC_CURRENT[4]+1,4); - gPC.printf("Completed CDMS HK\n"); + gPC.printf("\rCompleted CDMS HK\n"); /*---------------------------------- BAE HK --------------------------------------------*/ BAE_HK_I2C = FCTN_I2C_READ(BAE_HK,134); - gPC.printf("Entering BAE thread\n"); + gPC.printf("\rEntering BAE HK\n"); if(BAE_HK_I2C == 0) { - TIME_LATEST_I2C_BAE = FCTN_CDMS_RD_RTC() >> 7; + crc = crc16_gen((unsigned char *)BAE_HK,132); + if(crc == ((uint16_t)BAE_HK[132] << 8) | (uint16_t)BAE_HK[133]){ + TIME_LATEST_I2C_BAE = FCTN_CDMS_RD_RTC() >> 7; + for(int i = 0; i<15; i++) + gPC.printf("\r 0x%02X\n",BAE_HK[i]); + for(int i = 0; i<4; i++) + BAE_HK[i] = HK_time >> i; + BAE_HK_FRAME[0] = 0x28; + BAE_HK_FRAME[1] = FSC_CURRENT[5]+1; + BAE_HK_FRAME[2] = (FSC_CURRENT[5]+1) >> 8; + BAE_HK_FRAME[3] = (FSC_CURRENT[5]+1) >> 16; + for(int i = 0; i<128; i++) /*Adding actual CDMS Health data to TM frame*/ + BAE_HK_FRAME[4+i] = BAE_HK[i]; + crc = crc16_gen(BAE_HK_FRAME,132); /*Adding CRC to TM frame*/ + BAE_HK_FRAME[133] = crc; + BAE_HK_FRAME[132] = crc >> 8; + BAE_HEALTH.convolutionEncode(BAE_HK_FRAME , convoluted_BAE_HK); + BAE_HEALTH.convolutionEncode(BAE_HK_FRAME + 67, convoluted_BAE_HK + 135); + interleave(convoluted_BAE_HK , interleave_BAE_HK); + interleave(convoluted_BAE_HK +135, interleave_BAE_HK + 144); + for(int i=0; i<288; i++) + BAE_HEALTH_FINAL[i] = interleave_BAE_HK[i]; + SD_WRITE(BAE_HEALTH_FINAL,FSC_CURRENT[5]+1,5); + } + } else { - for(int i = 0; i<128; i++) + gPC.printf("\rBAE HK data not recieved through I2C\n"); + for(int i = 0; i<134; i++) BAE_HK[i] = 0; } - for(int i = 0; i<4; i++) - BAE_HK[i] = HK_time >> i; - BAE_HK_FRAME[0] = 0x28; - BAE_HK_FRAME[1] = FSC_CURRENT[5]+1; - BAE_HK_FRAME[2] = (FSC_CURRENT[5]+1) >> 8; - BAE_HK_FRAME[3] = (FSC_CURRENT[5]+1) >> 16; - for(int i = 0; i<128; i++) /*Adding actual CDMS Health data to TM frame*/ - BAE_HK_FRAME[4+i] = BAE_HK[i]; - crc = crc16_gen(BAE_HK_FRAME,132); /*Adding CRC to TM frame*/ - BAE_HK_FRAME[133] = crc; - BAE_HK_FRAME[132] = crc >> 8; - BAE_HEALTH.convolutionEncode(BAE_HK_FRAME , convoluted_BAE_HK); - BAE_HEALTH.convolutionEncode(BAE_HK_FRAME + 67, convoluted_BAE_HK + 135); - interleave(convoluted_BAE_HK , interleave_BAE_HK); - interleave(convoluted_BAE_HK +135, interleave_BAE_HK + 144); - for(int i=0; i<288; i++) - BAE_HEALTH_FINAL[i] = interleave_BAE_HK[i]; - SD_WRITE(BAE_HEALTH_FINAL,FSC_CURRENT[5]+1,5); - gPC.printf("Completed BAE HK\n"); + gPC.printf("\rCompleted BAE HK\n"); /*----------------------------------Beacon message--------------------------------------*/ unsigned char SC_HK_LBM_0[135]; @@ -135,7 +142,7 @@ SC_HK_LBM_0[132] = crc; SC_HK_LBM_0[133] = crc >> 8; FCTN_I2C_WRITE((char *)SC_HK_LBM_0,135); - gPC.printf("Completed Beacon\n"); + gPC.printf("\rCompleted Beacon\n"); } int quantiz(float start,float step,float x)