
CDMS code for testing sbc
Dependencies: FreescaleIAP SimpleDMA mbed-rtos mbed
Fork of CDMS_CODE by
Revision 216:570251b23c7b, committed 2016-07-03
- Comitter:
- chaithanyarss
- Date:
- Sun Jul 03 09:47:05 2016 +0000
- Parent:
- 214:867de6d350fa
- Child:
- 217:93505a6f8db7
- Commit message:
- Reset added
Changed in this revision
--- a/CDMS_HK.h Sun Jul 03 09:26:42 2016 +0000 +++ b/CDMS_HK.h Sun Jul 03 09:47:05 2016 +0000 @@ -1,11 +1,11 @@ //CDMS HK - #define COMRX_ALIVE 0xFF - #define COMRX_DEAD 0x00 - #define DEVICE_ENABLED 0x00 - #define DEVICE_POWERED 0x01 - #define DEVICE_OC_FAULT 0x02 - #define DEVICE_DISABLED 0x03 +#define COMRX_ALIVE 0x01 +#define COMRX_DEAD 0x00 +#define DEVICE_ENABLED 0x00 +#define DEVICE_POWERED 0x01 +#define DEVICE_OC_FAULT 0x02 +#define DEVICE_DISABLED 0x03 void FCTN_CDMS_HK_MAIN(); void FCTN_CDMS_HK(); @@ -35,119 +35,116 @@ void FCTN_CDMS_HK_MAIN(void const *args) { - unsigned char CDMS_HK_FRAME[134] = {0}; - char BAE_HK[128] = {0}; - uint8_t convoluted_CDMS_HK[270]; - uint8_t interleave_CDMS_HK[288]; - uint8_t CDMS_HEALTH_FINAL[512] = {0}; - uint8_t convoluted_BAE_HK[270]; - uint8_t interleave_BAE_HK[288]; - uint8_t BAE_HEALTH_FINAL[512] = {0}; - unsigned char BAE_HK_FRAME[134] = {0}; + unsigned char CDMS_HK_FRAME[134] = {0}; + char BAE_HK[128] = {0}; + uint8_t convoluted_CDMS_HK[270]; + uint8_t interleave_CDMS_HK[288]; + uint8_t CDMS_HEALTH_FINAL[512] = {0}; + uint8_t convoluted_BAE_HK[270]; + uint8_t interleave_BAE_HK[288]; + uint8_t BAE_HEALTH_FINAL[512] = {0}; + unsigned char BAE_HK_FRAME[134] = {0}; + + CDMS_HK_MAIN_STATUS = 0x01; + CDMS_HK_MAIN_COUNTER++; - CDMS_HK_MAIN_STATUS = 0x01; - CDMS_HK_MAIN_COUNTER++; + FCTN_CDMS_HK(); + RSSI_volatge = COMRX_RSSI_volatge.read() * 3.3; + VERIFY_COMRX(); + VERIFY_RTC(); + HANDLE_HW_FAULTS(); + FUNC_CDMS_GPIO_STATUS(); //yet to be done - FCTN_CDMS_HK(); - RSSI_volatge = COMRX_RSSI_volatge.read() * 3.3; - VERIFY_COMRX(); - VERIFY_RTC(); - HANDLE_HW_FAULTS(); - FUNC_CDMS_GPIO_STATUS(); //yet to be done + uint8_t CDMS_quant[19]; + for(int i=0; i<16; i++) { + CDMS_quant[i]= (uint8_t)quant_data.temp_quant[i]; + } + CDMS_quant[16]= (uint8_t)RSSI_volatge; + CDMS_quant[17]= (uint8_t)quant_data.CDMS_temp_quant; + minMaxHkData(); + + uint64_t time = FCTN_CDMS_RD_RTC(); //Reading Time from RTC + time = time>>7; + uint32_t HK_time = (uint32_t)time; + for(int i = 0; i<4; i++) + CDMS_HEALTH_DATA[i] = HK_time >> i; - uint8_t CDMS_quant[19]; - for(int i=0;i<16;i++) - { - CDMS_quant[i]= (uint8_t)quant_data.temp_quant[i]; - } - CDMS_quant[16]= (uint8_t)RSSI_volatge; - CDMS_quant[17]= (uint8_t)quant_data.CDMS_temp_quant; - minMaxHkData(); - - uint64_t time = FCTN_CDMS_RD_RTC(); //Reading Time from RTC - time = time>>7; - uint32_t HK_time = (uint32_t)time; - for(int i = 0;i<4;i++) - CDMS_HEALTH_DATA[i] = HK_time >> i; + // Here: Have to FIT flash data. + for(int i = 0; i<19; i++) //Collecting Data from Temp sensors + CDMS_HEALTH_DATA[i+24] = CDMS_quant[i]; + + COLLECT_CDMS_RAM(); //Reading RAM parameters + + CDMS_HEALTH_DATA[126] = GPIO_STATUS; //Reading GPIO Pins + CDMS_HEALTH_DATA[127] = GPIO_STATUS >> 8; + + FCTN_SD_MNGR(); //Adding FSC & TMID to TM frame + CDMS_HK_FRAME[0] = 0x20; + CDMS_HK_FRAME[1] = FSC_CURRENT[4]+1; + CDMS_HK_FRAME[2] = (FSC_CURRENT[4]+1) >> 8; + CDMS_HK_FRAME[3] = (FSC_CURRENT[4]+1) >> 16; - // Here: Have to FIT flash data. - for(int i = 0;i<19;i++) //Collecting Data from Temp sensors - CDMS_HEALTH_DATA[i+24] = CDMS_quant[i]; - - COLLECT_CDMS_RAM(); //Reading RAM parameters - - CDMS_HEALTH_DATA[126] = GPIO_STATUS; //Reading GPIO Pins - CDMS_HEALTH_DATA[127] = GPIO_STATUS >> 8; - - FCTN_SD_MNGR(); //Adding FSC & TMID to TM frame - CDMS_HK_FRAME[0] = 0x20; - CDMS_HK_FRAME[1] = FSC_CURRENT[4]+1; - CDMS_HK_FRAME[2] = (FSC_CURRENT[4]+1) >> 8; - CDMS_HK_FRAME[3] = (FSC_CURRENT[4]+1) >> 16; - - for(int i = 0;i<128;i++) /*Adding actual CDMS Health data to TM frame*/ - CDMS_HK_FRAME[4+i] = CDMS_HEALTH_DATA[i]; - - uint16_t crc = crc16_gen(CDMS_HK_FRAME,132); /*Adding CRC to TM frame*/ - CDMS_HK_FRAME[133] = crc; - CDMS_HK_FRAME[132] = crc >> 8; + for(int i = 0; i<128; i++) /*Adding actual CDMS Health data to TM frame*/ + CDMS_HK_FRAME[4+i] = CDMS_HEALTH_DATA[i]; + + uint16_t crc = crc16_gen(CDMS_HK_FRAME,132); /*Adding CRC to TM frame*/ + CDMS_HK_FRAME[133] = crc; + CDMS_HK_FRAME[132] = crc >> 8; - Convolution CDMS_HEALTH; - Convolution BAE_HEALTH; - CDMS_HEALTH.convolutionEncode(CDMS_HK_FRAME , convoluted_CDMS_HK); - CDMS_HEALTH.convolutionEncode(CDMS_HK_FRAME + 67, convoluted_CDMS_HK + 135); - interleave(convoluted_CDMS_HK , interleave_CDMS_HK); - interleave(convoluted_CDMS_HK +135, interleave_CDMS_HK + 144); - for(int i=0;i<288;i++) - CDMS_HEALTH_FINAL[i] = interleave_CDMS_HK[i]; + Convolution CDMS_HEALTH; + Convolution BAE_HEALTH; + CDMS_HEALTH.convolutionEncode(CDMS_HK_FRAME , convoluted_CDMS_HK); + CDMS_HEALTH.convolutionEncode(CDMS_HK_FRAME + 67, convoluted_CDMS_HK + 135); + interleave(convoluted_CDMS_HK , interleave_CDMS_HK); + interleave(convoluted_CDMS_HK +135, interleave_CDMS_HK + 144); + for(int i=0; i<288; i++) + CDMS_HEALTH_FINAL[i] = interleave_CDMS_HK[i]; - SD_WRITE(CDMS_HEALTH_FINAL,FSC_CURRENT[4]+1,4); - hk_cdms.printf("CDMS hk succesfully completed\r\n"); + SD_WRITE(CDMS_HEALTH_FINAL,FSC_CURRENT[4]+1,4); + hk_cdms.printf("CDMS hk succesfully completed\r\n"); -/*---------------------------------- BAE HK --------------------------------------------*/ - - - BAE_HK_I2C = FCTN_I2C_READ(BAE_HK,134); - if(BAE_HK_I2C == 0){ - TIME_LATEST_I2C_BAE = FCTN_CDMS_RD_RTC() >> 7; - hk_cdms.printf("Bae hk data received"); - } - else - { - for(int i = 0;i<128;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); - hk_cdms.printf("BAE hk succesfully completed\r\n"); - - /*----------------------------------Beacon message--------------------------------------*/ - unsigned char SC_HK_LBM_0[135]; - SC_HK_LBM_0[0] = 0; // Sending long beacon msg as telecommand with Packet sequence count 0x00 - // Add HK bits - - // Add SC bits - crc = crc16_gen(SC_HK_LBM_0,133); - SC_HK_LBM_0[132] = crc; - SC_HK_LBM_0[133] = crc >> 8; - FCTN_I2C_WRITE((char *)SC_HK_LBM_0,135); + /*---------------------------------- BAE HK --------------------------------------------*/ + + + BAE_HK_I2C = FCTN_I2C_READ(BAE_HK,134); + if(BAE_HK_I2C == 0) { + TIME_LATEST_I2C_BAE = FCTN_CDMS_RD_RTC() >> 7; + hk_cdms.printf("Bae hk data received"); + } else { + for(int i = 0; i<128; 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); + hk_cdms.printf("BAE hk succesfully completed\r\n"); + + /*----------------------------------Beacon message--------------------------------------*/ + unsigned char SC_HK_LBM_0[135]; + SC_HK_LBM_0[0] = 0; // Sending long beacon msg as telecommand with Packet sequence count 0x00 + // Add HK bits + + // Add SC bits + crc = crc16_gen(SC_HK_LBM_0,133); + SC_HK_LBM_0[132] = crc; + SC_HK_LBM_0[133] = crc >> 8; + FCTN_I2C_WRITE((char *)SC_HK_LBM_0,135); } int quantiz(float start,float step,float x) @@ -169,32 +166,30 @@ } void minMaxHkData() -{ - if(firstCount==true){ - for (int i = 0; i < 16; ++i){ - min_max_data.temp_min[i] = quant_data.temp_quant[i]; - min_max_data.temp_max[i] = quant_data.temp_quant[i]; +{ + if(firstCount==true) { + for (int i = 0; i < 16; ++i) { + min_max_data.temp_min[i] = quant_data.temp_quant[i]; + min_max_data.temp_max[i] = quant_data.temp_quant[i]; } min_max_data.CDMS_temp_min=quant_data.CDMS_temp_quant; min_max_data.CDMS_temp_max=quant_data.CDMS_temp_quant; - } - else { - for (int i = 0; i < 16; ++i) - { - min_max_data.temp_min[i] = saveMin(min_max_data.temp_min[i],quant_data.temp_quant[i]); - min_max_data.temp_max[i] = saveMax(min_max_data.temp_max[i],quant_data.temp_quant[i]); + } else { + for (int i = 0; i < 16; ++i) { + min_max_data.temp_min[i] = saveMin(min_max_data.temp_min[i],quant_data.temp_quant[i]); + min_max_data.temp_max[i] = saveMax(min_max_data.temp_max[i],quant_data.temp_quant[i]); } - + min_max_data.CDMS_temp_min = saveMin(min_max_data.CDMS_temp_min,quant_data.CDMS_temp_quant); min_max_data.CDMS_temp_max = saveMax(min_max_data.CDMS_temp_max,quant_data.CDMS_temp_quant); - } + } firstCount=false; } void FCTN_CDMS_HK() { - + int Iteration=0; SelectLinec0=0; @@ -202,7 +197,7 @@ SelectLinec2=0; SelectLinec3=0; - for(Iteration=0; Iteration<16; Iteration++){ + for(Iteration=0; Iteration<16; Iteration++) { actual_data.temp_actual[Iteration]=TempInput.read(); @@ -212,39 +207,35 @@ if(Iteration%4==3) SelectLinec2=!(SelectLinec2); if(Iteration%8==7) - SelectLinec3=!(SelectLinec3); + SelectLinec3=!(SelectLinec3); } actual_data.CDMS_temp_actual=(-90.7*3.3*CDMS_temp_sensor.read())+190.1543; - - for(Iteration=0;Iteration<16;Iteration++){ - if(Iteration<14){ + for(Iteration=0; Iteration<16; Iteration++) { + + if(Iteration<14) { actual_data.temp_actual[Iteration]=actual_data.temp_actual[Iteration]*3.3; - int resistance; - + int resistance; + resistance=24000*actual_data.temp_actual[Iteration]/(3.3-actual_data.temp_actual[Iteration]); - if(actual_data.temp_actual[Iteration]>1.47) - { + if(actual_data.temp_actual[Iteration]>1.47) { actual_data.temp_actual[Iteration]=3694/log(24.032242*resistance); - } - else{ - + } else { + actual_data.temp_actual[Iteration]=3365.4/log(7.60573*resistance); } - } - else + } else actual_data.temp_actual[Iteration]=(-90.7*3.3*actual_data.temp_actual[Iteration])+190.1543; } - for(Iteration=0;Iteration<16;Iteration++){ + for(Iteration=0; Iteration<16; Iteration++) { - if(Iteration<14){ + if(Iteration<14) { quant_data.temp_quant[Iteration]=quantiz(tstart_thermistor,tstep_thermistor,actual_data.temp_actual[Iteration]); - } - else + } else quant_data.temp_quant[Iteration]=quantiz(tstart,tstep,actual_data.temp_actual[Iteration]); } @@ -255,211 +246,195 @@ void FUNC_CDMS_GPIO_STATUS() //Polls the status of Input GPIO PINS { - //V_A_PGOOD //TRZ EN - GPIO_STATUS=(V_A_PGOOD)?(GPIO_STATUS)||((uint16_t)(0x1<<15)):(GPIO_STATUS)&(~((uint16_t)(0x1<<15))); - //V_B_PGOOD_1 //3V3BPGOOD //$ - GPIO_STATUS=(V_B_PGOOD_1)?(GPIO_STATUS)||((uint16_t)(0x1<<14)):(GPIO_STATUS)&(~((uint16_t)(0x1<<14))); - //V_B_PGOOD_2 //3V3BEN //$ - GPIO_STATUS=(V_B_PGOOD_2)?(GPIO_STATUS)||((uint16_t)(0x1<<13)):(GPIO_STATUS)&(~((uint16_t)(0x1<<13))); - //V_C_PGOOD //3V3CPGOOD //$ - GPIO_STATUS=(V_C_PGOOD)?(GPIO_STATUS)||((uint16_t)(0x1<<12)):(GPIO_STATUS)&(~((uint16_t)(0x1<<12))); - //COMRX_OC_FAULT //$ - GPIO_STATUS=(COMRX_OC_FAULT)?(GPIO_STATUS)||((uint16_t)(0x1<<11)):(GPIO_STATUS)&(~((uint16_t)(0x1<<11))); - // COMTX_OC_FAULT //$ - GPIO_STATUS=(COMTX_OC_FAULT)?(GPIO_STATUS)||((uint16_t)(0x1<<10)):(GPIO_STATUS)&(~((uint16_t)(0x1<<10))); - //BAE_OC_FAULT //$ - GPIO_STATUS=(BAE_OC_FAULT)?(GPIO_STATUS)||((uint16_t)(0x1<<9)):(GPIO_STATUS)&(~((uint16_t)(0x1<<9))); - //PL_GPIO_1_STATUS //$ - GPIO_STATUS=(PL_GPIO_1_STATUS)?(GPIO_STATUS)||((uint16_t)(0x1<<8)):(GPIO_STATUS)&(~((uint16_t)(0x1<<8))); - //PL_GPIO_2_STATUS //$ - GPIO_STATUS=(PL_GPIO_2_STATUS)?(GPIO_STATUS)||((uint16_t)(0x1<<7)):(GPIO_STATUS)&(~((uint16_t)(0x1<<7))); - //PL_GPIO_3_STATUS //$ - GPIO_STATUS=(PL_GPIO_3_STATUS)?(GPIO_STATUS)||((uint16_t)(0x1<<6)):(GPIO_STATUS)&(~((uint16_t)(0x1<<6))); - //PL_BEE_SW_OC_FAULT //to be verified - GPIO_STATUS=(PL_BEE_SW_OC_FAULT)?(GPIO_STATUS)||((uint16_t)(0x1<<5)):(GPIO_STATUS)&(~((uint16_t)(0x1<<5))); - //PL_EPS_LATCH_SW_OC_FAULT // to be verified - GPIO_STATUS=(PL_EPS_LATCH_SW_OC_FAULT)?(GPIO_STATUS)||((uint16_t)(0x1<<4)):(GPIO_STATUS)&(~((uint16_t)(0x1<<4))); + //V_A_PGOOD //TRZ EN + GPIO_STATUS=(V_A_PGOOD)?(GPIO_STATUS)||((uint16_t)(0x1<<15)):(GPIO_STATUS)&(~((uint16_t)(0x1<<15))); + //V_B_PGOOD_1 //3V3BPGOOD //$ + GPIO_STATUS=(V_B_PGOOD_1)?(GPIO_STATUS)||((uint16_t)(0x1<<14)):(GPIO_STATUS)&(~((uint16_t)(0x1<<14))); + //V_B_PGOOD_2 //3V3BEN //$ + GPIO_STATUS=(V_B_PGOOD_2)?(GPIO_STATUS)||((uint16_t)(0x1<<13)):(GPIO_STATUS)&(~((uint16_t)(0x1<<13))); + //V_C_PGOOD //3V3CPGOOD //$ + GPIO_STATUS=(V_C_PGOOD)?(GPIO_STATUS)||((uint16_t)(0x1<<12)):(GPIO_STATUS)&(~((uint16_t)(0x1<<12))); + //COMRX_OC_FAULT //$ + GPIO_STATUS=(COMRX_OC_FAULT)?(GPIO_STATUS)||((uint16_t)(0x1<<11)):(GPIO_STATUS)&(~((uint16_t)(0x1<<11))); + // COMTX_OC_FAULT //$ + GPIO_STATUS=(COMTX_OC_FAULT)?(GPIO_STATUS)||((uint16_t)(0x1<<10)):(GPIO_STATUS)&(~((uint16_t)(0x1<<10))); + //BAE_OC_FAULT //$ + GPIO_STATUS=(BAE_OC_FAULT)?(GPIO_STATUS)||((uint16_t)(0x1<<9)):(GPIO_STATUS)&(~((uint16_t)(0x1<<9))); + //PL_GPIO_1_STATUS //$ + GPIO_STATUS=(PL_GPIO_1_STATUS)?(GPIO_STATUS)||((uint16_t)(0x1<<8)):(GPIO_STATUS)&(~((uint16_t)(0x1<<8))); + //PL_GPIO_2_STATUS //$ + GPIO_STATUS=(PL_GPIO_2_STATUS)?(GPIO_STATUS)||((uint16_t)(0x1<<7)):(GPIO_STATUS)&(~((uint16_t)(0x1<<7))); + //PL_GPIO_3_STATUS //$ + GPIO_STATUS=(PL_GPIO_3_STATUS)?(GPIO_STATUS)||((uint16_t)(0x1<<6)):(GPIO_STATUS)&(~((uint16_t)(0x1<<6))); + //PL_BEE_SW_OC_FAULT //to be verified + GPIO_STATUS=(PL_BEE_SW_OC_FAULT)?(GPIO_STATUS)||((uint16_t)(0x1<<5)):(GPIO_STATUS)&(~((uint16_t)(0x1<<5))); + //PL_EPS_LATCH_SW_OC_FAULT // to be verified + GPIO_STATUS=(PL_EPS_LATCH_SW_OC_FAULT)?(GPIO_STATUS)||((uint16_t)(0x1<<4)):(GPIO_STATUS)&(~((uint16_t)(0x1<<4))); } void VERIFY_COMRX() { - //COMRX_OC_FAULT //$ - if(PIN68==0 && RSSI_volatge > 0.4) - { - COMRX_STATUS = COMRX_ALIVE; - } - else - { - RESET_COMRX(); - COMRX_RESET_COUNTER++; - if(PIN68==0 && RSSI_volatge > 0.4) - COMRX_STATUS = COMRX_ALIVE; - else - COMRX_STATUS = COMRX_DEAD; - } + //COMRX_OC_FAULT //$ + if(PIN68==0 && RSSI_volatge > 0.4) { + COMRX_STATUS = COMRX_ALIVE; + } else { + RESET_COMRX(); + COMRX_RESET_COUNTER++; + if(PIN68==0 && RSSI_volatge > 0.4) + COMRX_STATUS = COMRX_ALIVE; + else + COMRX_STATUS = COMRX_DEAD; + } } -void VERIFY_RTC(){ +void VERIFY_RTC() +{ - if(RTC_STATUS == 0x00) - { - SPI_mutex.lock(); - gCS_RTC=1; - gCS_RTC=0; - spi.write(0x0F); - if(spi.write(0x00) & 0x04 == 0x04) - { - RTC_STATUS = 0x00; - RESET_RTC(); - RTC_FAULTCOUNT++; + if(RTC_STATUS == 0x00) { + SPI_mutex.lock(); + gCS_RTC=1; + gCS_RTC=0; + spi.write(0x0F); + if(spi.write(0x00) & 0x04 == 0x04) { + RTC_STATUS = 0x00; + RESET_RTC(); + RTC_FAULTCOUNT++; + } + gCS_RTC=1; + SPI_mutex.unlock(); } - gCS_RTC=1; - SPI_mutex.unlock(); - } } void HANDLE_HW_FAULTS() { - HANDLE_HW_FAULT_SD(); - HANDLE_HW_FAULT_BAE(); - HANDLE_HW_FAULT_PL(); + HANDLE_HW_FAULT_SD(); + HANDLE_HW_FAULT_BAE(); + HANDLE_HW_FAULT_PL(); } void HANDLE_HW_FAULT_SD() { - if(SD_STATUS != DEVICE_DISABLED) - { - if(SD_STATUS == DEVICE_OC_FAULT) - SD_SW_EN_DS = 0; //powering on SD + if(SD_STATUS != DEVICE_DISABLED) { + if(SD_STATUS == DEVICE_OC_FAULT) + SD_SW_EN_DS = 0; //powering on SD + + if(SD_OC_FAULT == 0) { + SD_SW_EN_DS = 1; //switching off SD card - if(SD_OC_FAULT == 0) - { - SD_SW_EN_DS = 1; //switching off SD card - - SD_FAULTCOUNT++; - SD_STATUS = (SD_FAULTCOUNT == 3) ? DEVICE_DISABLED :DEVICE_OC_FAULT; + SD_FAULTCOUNT++; + SD_STATUS = (SD_FAULTCOUNT == 3) ? DEVICE_DISABLED :DEVICE_OC_FAULT; + } else { + SD_STATUS = DEVICE_POWERED; + SD_FAULTCOUNT = 0; + } } - else - { - SD_STATUS = DEVICE_POWERED; - SD_FAULTCOUNT = 0; - } - } } void HANDLE_HW_FAULT_BAE() { - if(BAE_STATUS != DEVICE_DISABLED) - { - if(BAE_STATUS == DEVICE_OC_FAULT) - BAE_SW_EN_DS = 0; //Power ON BAE + if(BAE_STATUS != DEVICE_DISABLED) { + if(BAE_STATUS == DEVICE_OC_FAULT) + BAE_SW_EN_DS = 0; //Power ON BAE - if(BAE_OC_FAULT == 0) // If OC Fault - { - BAE_SW_EN_DS = 1; //Switch OFF BAE - BAE_FAULTCOUNT++; - BAE_STATUS = (BAE_FAULTCOUNT == 3)?DEVICE_DISABLED:DEVICE_OC_FAULT; + if(BAE_OC_FAULT == 0) { // If OC Fault + BAE_SW_EN_DS = 1; //Switch OFF BAE + BAE_FAULTCOUNT++; + BAE_STATUS = (BAE_FAULTCOUNT == 3)?DEVICE_DISABLED:DEVICE_OC_FAULT; + } else { + BAE_STATUS = DEVICE_POWERED; + BAE_FAULTCOUNT = 0; + } } - else - { - BAE_STATUS = DEVICE_POWERED; - BAE_FAULTCOUNT = 0; - } - } } void HANDLE_HW_FAULT_PL() { - if(PL_STATUS != DEVICE_DISABLED) - { - if(PL_STATUS == DEVICE_OC_FAULT) - PL_SW_EN_DS = 0; //Power ON PL + if(PL_STATUS != DEVICE_DISABLED) { + if(PL_STATUS == DEVICE_OC_FAULT) + PL_SW_EN_DS = 0; //Power ON PL - if(PL_BEE_SW_OC_FAULT == 0) // if OC Fault - { - PL_SW_EN_DS = 1; // switching OFF PL - PL_FAULTCOUNT++; - PL_STATUS = (PL_FAULTCOUNT == 3)?DEVICE_DISABLED:DEVICE_OC_FAULT; + if(PL_BEE_SW_OC_FAULT == 0) { // if OC Fault + PL_SW_EN_DS = 1; // switching OFF PL + PL_FAULTCOUNT++; + PL_STATUS = (PL_FAULTCOUNT == 3)?DEVICE_DISABLED:DEVICE_OC_FAULT; + } else { + if(PL_STATUS == DEVICE_OC_FAULT) + PL_SW_EN_DS = 0; //Switching OFF PL + PL_STATUS = DEVICE_ENABLED; + PL_FAULTCOUNT = 0; + } } - else - { - if(PL_STATUS == DEVICE_OC_FAULT) - PL_SW_EN_DS = 0; //Switching OFF PL - PL_STATUS = DEVICE_ENABLED; - PL_FAULTCOUNT = 0; - } - } } - + void COLLECT_CDMS_RAM() -{ - /*--------------------Current FSC's---------------------*/ - for(int i=0;i<4;i++) - CDMS_HEALTH_DATA[i+43] = FSC_LAST[5] >> (i*8); - for(int i=0;i<4;i++) - CDMS_HEALTH_DATA[i+47] = FSC_CURRENT[5] >> (i*8); - for(int i=0;i<4;i++) - CDMS_HEALTH_DATA[i+51] = FSC_LAST[4] >> (i*8); - for(int i=0;i<4;i++) - CDMS_HEALTH_DATA[i+55] = FSC_CURRENT[4] >> (i*8); - for(int i=0;i<4;i++) - CDMS_HEALTH_DATA[i+59] = FSC_LAST[3] >> (i*8); - for(int i=0;i<4;i++) - CDMS_HEALTH_DATA[i+63] = FSC_CURRENT[3] >> (i*8); - for(int i=0;i<4;i++) - CDMS_HEALTH_DATA[i+67] = FSC_LAST[2] >> (i*8); - for(int i=0;i<4;i++) - CDMS_HEALTH_DATA[i+71] = FSC_CURRENT[2] >> (i*8); - for(int i=0;i<4;i++) - CDMS_HEALTH_DATA[i+75] = FSC_LAST[1] >> (i*8); - for(int i=0;i<4;i++) - CDMS_HEALTH_DATA[i+79] = FSC_CURRENT[1] >> (i*8); - /*---------------------Latest Time----------------------*/ - for(int i=0;i<4;i++) - CDMS_HEALTH_DATA[i+83] = TIME_LATEST_SPI_SPEED >> (i*8); - for(int i=0;i<4;i++) - CDMS_HEALTH_DATA[i+87] = TIME_LATEST_SD_RD >> (i*8); - for(int i=0;i<4;i++) - CDMS_HEALTH_DATA[i+91] = TIME_LATEST_SD_WR >> (i*8); - for(int i=0;i<4;i++) - CDMS_HEALTH_DATA[i+95] = TIME_LATEST_I2C_SPEED >> (i*8); - for(int i=0;i<4;i++) - CDMS_HEALTH_DATA[i+99] = TIME_LATEST_I2C_BAE >> (i*8); - for(int i=0;i<4;i++) - CDMS_HEALTH_DATA[i+103] = TIME_LATEST_RTC >> (i*8); - for(int i=0;i<2;i++) - CDMS_HEALTH_DATA[i+107] = COMRX_RESET_COUNTER >> (i*8); - for(int i=0;i<2;i++) - CDMS_HEALTH_DATA[i+107] = PL_RCV_SC_DATA_COUNTER >> (i*8); - for(int i=0;i<2;i++) - CDMS_HEALTH_DATA[i+111] = PL_MAIN_COUNTER >> (i*8); - for(int i=0;i<2;i++) - CDMS_HEALTH_DATA[i+113] = CDMS_HK_MAIN_COUNTER >> (i*8); - for(int i=0;i<2;i++) - CDMS_HEALTH_DATA[i+115] = CDMS_I2C_ERR_BAE_COUNTER >> (i*8); - for(int i=0;i<2;i++) - CDMS_HEALTH_DATA[i+117] = CDMS_I2C_ERR_SPEED_COUNTER >> (i*8); - CDMS_HEALTH_DATA[120] = CDMS_HEALTH_DATA[120] | CDMS_STANDBY_PL << 7; - CDMS_HEALTH_DATA[120] = CDMS_HEALTH_DATA[120] | ((CDMS_INIT_STATUS << 6) & 0x40); - CDMS_HEALTH_DATA[120] = CDMS_HEALTH_DATA[120] | ((CDMS_HK_MAIN_STATUS << 5) & 0x20); - CDMS_HEALTH_DATA[120] = CDMS_HEALTH_DATA[120] | ((CDMS_HK_STATUS << 3) & 0x18); - CDMS_HEALTH_DATA[120] = CDMS_HEALTH_DATA[120] | ((COMRX_STATUS << 2) & 0x04); - CDMS_HEALTH_DATA[120] = CDMS_HEALTH_DATA[120] | ((CDMS_RTC_BL << 1) & 0x02); - CDMS_HEALTH_DATA[120] = CDMS_HEALTH_DATA[120] & 0xFE; - - CDMS_HEALTH_DATA[121] = CDMS_HEALTH_DATA[121] | PL_RCV_SC_DATA_STATUS << 7; - CDMS_HEALTH_DATA[121] = CDMS_HEALTH_DATA[121] | ((COM_SESSION << 6) & 0x40); - CDMS_HEALTH_DATA[121] = CDMS_HEALTH_DATA[121] | ((COM_RX << 5) & 0x20); - CDMS_HEALTH_DATA[121] = CDMS_HEALTH_DATA[121] | ((RF_SW_STATUS << 4) & 0x10); - CDMS_HEALTH_DATA[121] = CDMS_HEALTH_DATA[121] | ((COM_TX << 3) & 0x08); - CDMS_HEALTH_DATA[121] = CDMS_HEALTH_DATA[121] | ((COM_TX_STATUS << 2) & 0x04); - CDMS_HEALTH_DATA[121] = CDMS_HEALTH_DATA[121] | ((COM_MNG_TMTC << 1) & 0x02); - CDMS_HEALTH_DATA[121] = CDMS_HEALTH_DATA[121] | (CDMS_STANDBY_HK & 0x01); +{ + /*--------------------Current FSC's---------------------*/ + for(int i=0; i<4; i++) + CDMS_HEALTH_DATA[i+43] = FSC_LAST[5] >> (i*8); + for(int i=0; i<4; i++) + CDMS_HEALTH_DATA[i+47] = FSC_CURRENT[5] >> (i*8); + for(int i=0; i<4; i++) + CDMS_HEALTH_DATA[i+51] = FSC_LAST[4] >> (i*8); + for(int i=0; i<4; i++) + CDMS_HEALTH_DATA[i+55] = FSC_CURRENT[4] >> (i*8); + for(int i=0; i<4; i++) + CDMS_HEALTH_DATA[i+59] = FSC_LAST[3] >> (i*8); + for(int i=0; i<4; i++) + CDMS_HEALTH_DATA[i+63] = FSC_CURRENT[3] >> (i*8); + for(int i=0; i<4; i++) + CDMS_HEALTH_DATA[i+67] = FSC_LAST[2] >> (i*8); + for(int i=0; i<4; i++) + CDMS_HEALTH_DATA[i+71] = FSC_CURRENT[2] >> (i*8); + for(int i=0; i<4; i++) + CDMS_HEALTH_DATA[i+75] = FSC_LAST[1] >> (i*8); + for(int i=0; i<4; i++) + CDMS_HEALTH_DATA[i+79] = FSC_CURRENT[1] >> (i*8); + /*---------------------Latest Time----------------------*/ + for(int i=0; i<4; i++) + CDMS_HEALTH_DATA[i+83] = TIME_LATEST_SPI_SPEED >> (i*8); + for(int i=0; i<4; i++) + CDMS_HEALTH_DATA[i+87] = TIME_LATEST_SD_RD >> (i*8); + for(int i=0; i<4; i++) + CDMS_HEALTH_DATA[i+91] = TIME_LATEST_SD_WR >> (i*8); + for(int i=0; i<4; i++) + CDMS_HEALTH_DATA[i+95] = TIME_LATEST_I2C_SPEED >> (i*8); + for(int i=0; i<4; i++) + CDMS_HEALTH_DATA[i+99] = TIME_LATEST_I2C_BAE >> (i*8); + for(int i=0; i<4; i++) + CDMS_HEALTH_DATA[i+103] = TIME_LATEST_RTC >> (i*8); + for(int i=0; i<2; i++) + CDMS_HEALTH_DATA[i+107] = COMRX_RESET_COUNTER >> (i*8); + for(int i=0; i<2; i++) + CDMS_HEALTH_DATA[i+107] = PL_RCV_SC_DATA_COUNTER >> (i*8); + for(int i=0; i<2; i++) + CDMS_HEALTH_DATA[i+111] = PL_MAIN_COUNTER >> (i*8); + for(int i=0; i<2; i++) + CDMS_HEALTH_DATA[i+113] = CDMS_HK_MAIN_COUNTER >> (i*8); + for(int i=0; i<2; i++) + CDMS_HEALTH_DATA[i+115] = CDMS_I2C_ERR_BAE_COUNTER >> (i*8); + for(int i=0; i<2; i++) + CDMS_HEALTH_DATA[i+117] = CDMS_I2C_ERR_SPEED_COUNTER >> (i*8); + CDMS_HEALTH_DATA[120] = CDMS_HEALTH_DATA[120] | CDMS_STANDBY_PL << 7; + CDMS_HEALTH_DATA[120] = CDMS_HEALTH_DATA[120] | ((CDMS_INIT_STATUS << 6) & 0x40); + CDMS_HEALTH_DATA[120] = CDMS_HEALTH_DATA[120] | ((CDMS_HK_MAIN_STATUS << 5) & 0x20); + CDMS_HEALTH_DATA[120] = CDMS_HEALTH_DATA[120] | ((CDMS_HK_STATUS << 3) & 0x18); + CDMS_HEALTH_DATA[120] = CDMS_HEALTH_DATA[120] | ((COMRX_STATUS << 2) & 0x04); + CDMS_HEALTH_DATA[120] = CDMS_HEALTH_DATA[120] | ((CDMS_RTC_BL << 1) & 0x02); + CDMS_HEALTH_DATA[120] = CDMS_HEALTH_DATA[120] & 0xFE; - CDMS_HEALTH_DATA[122] = CDMS_HEALTH_DATA[122] | PL_INIT_STATUS << 7; - CDMS_HEALTH_DATA[122] = CDMS_HEALTH_DATA[122] | ((PL_MAIN_STATUS << 6) & 0x40); - CDMS_HEALTH_DATA[122] = CDMS_HEALTH_DATA[122] | ((PL_LOW_POWER << 5) & 0x20); - CDMS_HEALTH_DATA[122] = CDMS_HEALTH_DATA[122] | ((PL_STATE << 3) & 0x18); - CDMS_HEALTH_DATA[122] = CDMS_HEALTH_DATA[122] | (PL_STATUS & 0x07); + CDMS_HEALTH_DATA[121] = CDMS_HEALTH_DATA[121] | PL_RCV_SC_DATA_STATUS << 7; + CDMS_HEALTH_DATA[121] = CDMS_HEALTH_DATA[121] | ((COM_SESSION << 6) & 0x40); + CDMS_HEALTH_DATA[121] = CDMS_HEALTH_DATA[121] | ((COM_RX << 5) & 0x20); + CDMS_HEALTH_DATA[121] = CDMS_HEALTH_DATA[121] | ((RF_SW_STATUS << 4) & 0x10); + CDMS_HEALTH_DATA[121] = CDMS_HEALTH_DATA[121] | ((COM_TX << 3) & 0x08); + CDMS_HEALTH_DATA[121] = CDMS_HEALTH_DATA[121] | ((COM_TX_STATUS << 2) & 0x04); + CDMS_HEALTH_DATA[121] = CDMS_HEALTH_DATA[121] | ((COM_MNG_TMTC << 1) & 0x02); + CDMS_HEALTH_DATA[121] = CDMS_HEALTH_DATA[121] | (CDMS_STANDBY_HK & 0x01); + + CDMS_HEALTH_DATA[122] = CDMS_HEALTH_DATA[122] | PL_INIT_STATUS << 7; + CDMS_HEALTH_DATA[122] = CDMS_HEALTH_DATA[122] | ((PL_MAIN_STATUS << 6) & 0x40); + CDMS_HEALTH_DATA[122] = CDMS_HEALTH_DATA[122] | ((PL_LOW_POWER << 5) & 0x20); + CDMS_HEALTH_DATA[122] = CDMS_HEALTH_DATA[122] | ((PL_STATE << 3) & 0x18); + CDMS_HEALTH_DATA[122] = CDMS_HEALTH_DATA[122] | (PL_STATUS & 0x07); } \ No newline at end of file
--- a/CDMS_PL.h Sun Jul 03 09:26:42 2016 +0000 +++ b/CDMS_PL.h Sun Jul 03 09:47:05 2016 +0000 @@ -6,7 +6,6 @@ uint32_t pl_time; uint32_t TIME_LATEST_PL=0; uint8_t i; -uint8_t PL_BEE_SW_STATUS=0; //Serial pc(USBTX,USBRX);
--- a/COM_MNG_TMTC.h Sun Jul 03 09:26:42 2016 +0000 +++ b/COM_MNG_TMTC.h Sun Jul 03 09:47:05 2016 +0000 @@ -45,7 +45,7 @@ -#define detect_ack(tm_ptr, temp_ack) {\ +#define detect_ack(tm_ptr, temp_ack, tc_psc) {\ if( tm_ptr != NULL ){\ int length = TM_SHORT_SIZE;\ if( GETshort_or_long_tm(tm_ptr) == SHORT_TM_CODE ){\ @@ -62,20 +62,20 @@ if( (temp8 == 0xC0) || (temp8 == 0xA0) )\ temp_ack = 0x01;\ else{\ - temp_ack = 0x02;\ + temp_ack = 0x00;\ /*CHECK FOR NACK CODE: CRC FAIL NACK*/\ temp8 = tm_ptr->TM_string[TM_ACK_CODE_INDEX];\ temp8 = temp8 & 0x0F;\ if( temp8 == CRC_FAIL_NACK_CODE ){\ - temp_ack = 0x04;\ + tm_ptr->TM_string[2] = tc_psc;\ }\ }\ }\ else\ - temp_ack = 0x03;\ + temp_ack = 0x00;\ }\ else{\ - temp_ack = 0x02;\ + temp_ack = 0x00;\ }\ } @@ -942,7 +942,6 @@ return; } // CDMS TEAM CODE END - // EXECUTE OBOSC #define execute_obosc_core(tc_ptr, tm_ptr, reset_flag) {\ if (DEBUG)\ @@ -975,7 +974,7 @@ ++modify_overflow;\ }\ else{\ - RESET_CDMS;\ + RESET_CDMS();\ break;\ }\ }\ @@ -998,7 +997,7 @@ ++modify_overflow;\ }\ else{\ - RESET_CDMS;\ + RESET_CDMS();\ break;\ }\ }\ @@ -1042,11 +1041,13 @@ get_tc_list(ackl234new->next_TM, GETpacket_seq_count(tc_ptr));\ }\ else if( service_subtype == OBOSC_SUB_RESET ){\ + /*reset_all;*/\ reset_flag = 1;\ + /*PENDING: VERIFY reset_all, RESET CDMS*/\ }\ else if( (service_subtype != OBOSC_SUB_DISABLE) && (service_subtype != OBOSC_SUB_RETRY) ){\ /*CHANGE THE ACK CODE TO INVALID TC*/\ - ackl234new->TM_string[2] = 0xAF;\ + ackl234new->TM_string[2] = 0xA2;\ }\ if (DEBUG)\ gPC.puts("completed obosc\r\n");\ @@ -1056,7 +1057,6 @@ #define EXECUTE_OBOSC_ONLY {\ - gMASTER_STATE = TCL_STATE_EXECUTING;\ int reset_flag = 0;\ if (DEBUG)\ gPC.puts("iNSIDE EXECUTE_OBOSC_ONLY\r\n");\ @@ -1085,14 +1085,8 @@ while(obosc_tm_core != NULL){\ obosc_tm_core = obosc_tm_core->next_TM;\ }\ - if(obosc_tm_current->TM_string[2] == 0xA0){\ - uint16_t temp16 = TC_STATE_SUCCESSFULLY_EXECUTED;\ - PUTexec_status(current_TC, temp16);\ - }\ - else{\ - uint16_t temp16 = TC_STATE_EXECUTION_FAILED;\ - PUTexec_status(current_TC, temp16);\ - }\ + uint16_t temp16 = TC_STATE_SUCCESSFULLY_EXECUTED;\ + PUTexec_status(current_TC, temp16);\ while( obosc_tm_current != NULL ){\ int length = TM_SHORT_SIZE;\ if( GETshort_or_long_tm(obosc_tm_current) == SHORT_TM_CODE ){\ @@ -1106,6 +1100,9 @@ }\ obosc_tm_current = obosc_tm_current->next_TM;\ }\ + if ( reset_flag ==1 ){\ + reset_all;\ + }\ }\ }\ }\ @@ -1113,7 +1110,7 @@ ++overCount;\ }\ else{\ - RESET_CDMS;\ + /*PENDING: REST CDMS: MEMORY LEAK FOUND*/\ break;\ }\ }\ @@ -1130,7 +1127,7 @@ ++overflowCountOBONLY;\ }\ else{\ - RESET_CDMS;\ + RESET_CDMS();\ break;\ }\ }\ @@ -1149,17 +1146,11 @@ ++overCount;\ }\ else{\ - RESET_CDMS;\ + RESET_CDMS();\ break;\ }\ }\ - }\ - if ( reset_flag == 1 ){\ - reset_all;\ - /*PENDING: Enable threads*/\ - /*gCDMS_HK_TIMER.start(5000);*/\ - gSESSION_TIMEOUT.detach();\ - }\ + }\ } #define EXECUTE_TC {\ @@ -1222,7 +1213,7 @@ ++overflowCountExecute;\ }\ else{\ - RESET_CDMS;\ + RESET_CDMS();\ break;\ }\ }\ @@ -1250,37 +1241,25 @@ }\ else{\ /*gPC.printf("cdms relay tmtc at %u\r\n", execute_psc);*/\ + /*call CDMS_RLY_TMTC*/\ + /*CDMS_RLY_TMTC(current_TC, put_tm_here);*/\ put_tm_here = FCTN_CDMS_RLY_TMTC(current_TC);\ }\ /*DETECT ACK OR NACK*/\ uint8_t temp83 = 0x00;\ - detect_ack(put_tm_here, temp83);\ + uint8_t temp84 = GETpacket_seq_count(current_TC);\ + detect_ack(put_tm_here, temp83, temp84);\ if( temp83 == 0x01){\ uint16_t temp16 = TC_STATE_SUCCESSFULLY_EXECUTED;\ PUTexec_status(current_TC, temp16);\ }\ - else if( temp83 == 0x03){\ - /*gPC.puts("TC_STATE_EXECUTION_UNKNOWN");*/\ - uint16_t temp16 = TC_STATE_EXECUTION_UNKNOWN;\ - PUTexec_status(current_TC, temp16);\ - }\ - else if( temp83 == 0x04){\ - /*gPC.puts("TC_STATE_EXECUTION_UNKNOWN");*/\ - uint16_t temp16 = TC_STATE_EXECUTION_FAILED;\ - PUTexec_status(current_TC, temp16);\ - uint8_t temp84 = GETpacket_seq_count(current_TC);\ - put_tm_here->TM_string[2] = temp84;\ - uint16_t crc16 = crc16_gen(put_tm_here->TM_string, 11);\ - put_tm_here->TM_string[11] = (crc16 & 0xFF00)>>8;\ - put_tm_here->TM_string[12] = (crc16 & 0x00FF);\ - }\ else{\ /*gPC.puts("TC_STATE_EXECUTION_FAILED");*/\ uint16_t temp16 = TC_STATE_EXECUTION_FAILED;\ PUTexec_status(current_TC, temp16);\ }\ /*ABORT ON NACK AND TC LIST COMPLETED: UPDATE IN gMASTERSTATE*/\ - if( ((GETexec_status(current_TC) == TC_STATE_EXECUTION_FAILED) || (GETexec_status(current_TC) == TC_STATE_EXECUTION_UNKNOWN)) && (GETabort_on_nack(current_TC) == 1) ){\ + if( (GETexec_status(current_TC) == TC_STATE_EXECUTION_FAILED) && (GETabort_on_nack(current_TC) == 1) ){\ gMASTER_STATE = TCL_STATE_ABORTED;\ }\ else if( execute_psc == (gTOTAL_VALID_TC-1) ){\ @@ -1289,23 +1268,20 @@ }\ /*update last executed L1_ack*/\ if( put_tm_here != NULL ){\ - Base_tm *ptr_tm = put_tm_here;\ - while(ptr_tm->next_TM != NULL)\ - ptr_tm = ptr_tm->next_TM;\ - if( GETshort_or_long_tm(ptr_tm) == SHORT_TM_CODE ){\ + if( GETshort_or_long_tm(put_tm_here) == SHORT_TM_CODE ){\ for(int i = 0 ; i < TM_SHORT_SIZE ; ++i){\ - gLAST_TM[i] = ptr_tm->TM_string[i];\ + gLAST_TM[i] = put_tm_here->TM_string[i];\ gLAST_TM_SHORT_OR_LONG = SHORT_TM_CODE;\ }\ }\ else{\ for( int i = 0 ; i < TM_LONG_SIZE ; ++i ){\ - gLAST_TM[i] = ptr_tm->TM_string[i];\ + gLAST_TM[i] = put_tm_here->TM_string[i];\ gLAST_TM_SHORT_OR_LONG = LONG_TM_CODE;\ }\ }\ }\ - P_COM_HK;\ + /*PENDING: APPEND ACK L1*/\ Base_tm *tm_ptr = tm_ptr_head;\ get_ack_l1(tm_ptr->next_TM);\ int overflowCountExecute = 0;\ @@ -1315,11 +1291,16 @@ ++overflowCountExecute;\ }\ else{\ - RESET_CDMS;\ + RESET_CDMS();\ break;\ }\ }\ tm_ptr->next_TM = put_tm_here;\ + /*CHECK FOR HOT PA*/\ + isPAhot(tempPAhot);\ + if( tempPAhot == 0x00 ){\ + gFLAGS = gFLAGS | COM_PA_HOT_FLAG;\ + }\ tm_ptr = tm_ptr_head;\ while( tm_ptr != NULL ){\ int length = TM_SHORT_SIZE;\ @@ -1351,7 +1332,7 @@ ++overflowCountExecute;\ }\ else{\ - RESET_CDMS;\ + RESET_CDMS();\ break;\ }\ }\ @@ -1360,7 +1341,112 @@ if (DEBUG)\ gPC.printf("sd card at %u\r\n", execute_psc);\ /*EXECUTION OF SD-CARD DATA SENDING (OBSRS)*/\ + Base_tm *tm_ptr_head = NULL;\ + get_call_sign(tm_ptr_head);\ + Base_tm *put_tm_here = NULL;\ + /*execute_obsrs(current_TC, put_tm_here)*/\ + /*read_TC(current_TC);*/\ execute_OBSRS_TC(current_TC);\ + gPC.puts("en_adf");\ + transmit_adf;\ + gPC.puts("ex_adf");\ + uint8_t tempExec = TC_STATE_SUCCESSFULLY_EXECUTED;\ + PUTexec_status(current_TC, tempExec);\ + /*PENDING: ABORT ON NACK CHECK, gMASTER_STATE VERIFICATION WITH SD CARD, session timeout, last executed ack l234*/\ + if( (GETexec_status(current_TC) == TC_STATE_EXECUTION_FAILED) && (GETabort_on_nack(current_TC) == 1) ){\ + gMASTER_STATE = TCL_STATE_ABORTED;\ + }\ + else if( execute_psc == (gTOTAL_VALID_TC-1) ){\ + gMASTER_STATE = TCL_STATE_COMPLETED;\ + }\ + else{\ + uint8_t check1 = 1;\ + for( uint8_t test_psc = execute_psc+1 ; test_psc < gTOTAL_VALID_TC ; ++test_psc ){\ + Base_tc* test_TC = gHEAD_NODE_TCL;\ + while(test_TC != NULL){\ + if( GETpacket_seq_count(test_TC) == test_psc ){\ + uint8_t checkval;\ + isit_obosc(test_TC, checkval);\ + if( checkval == 0 ){\ + check1 = 0;\ + }\ + }\ + test_TC = test_TC->next_TC;\ + }\ + }\ + if( check1 == 0x01 ){\ + gMASTER_STATE = TCL_STATE_COMPLETED;\ + }\ + }\ + /*update last executed L1_ack*/\ + if( put_tm_here != NULL ){\ + if( GETshort_or_long_tm(put_tm_here) == SHORT_TM_CODE ){\ + for(int i = 0 ; i < TM_SHORT_SIZE ; ++i){\ + gLAST_TM[i] = put_tm_here->TM_string[i];\ + gLAST_TM_SHORT_OR_LONG = SHORT_TM_CODE;\ + }\ + }\ + else{\ + for( int i = 0 ; i < TM_LONG_SIZE ; ++i ){\ + gLAST_TM[i] = put_tm_here->TM_string[i];\ + gLAST_TM_SHORT_OR_LONG = LONG_TM_CODE;\ + }\ + }\ + }\ + /*PENDING: APPEND ACK L1*/\ + Base_tm *tm_ptr = tm_ptr_head;\ + get_ack_l1(tm_ptr->next_TM);\ + int overflowCountExecute = 0;\ + while( tm_ptr->next_TM != NULL ){\ + if( overflowCountExecute < TM_OVERFLOW_CONSTANT ){\ + tm_ptr = tm_ptr->next_TM;\ + ++overflowCountExecute;\ + }\ + else{\ + RESET_CDMS();\ + break;\ + }\ + }\ + tm_ptr->next_TM = put_tm_here;\ + /*CHECK FOR HOT PA*/\ + uint8_t tempPAhot = 0x00;\ + isPAhot(tempPAhot);\ + if( tempPAhot == 0x00 ){\ + gFLAGS = gFLAGS | COM_PA_HOT_FLAG;\ + }\ + tm_ptr = tm_ptr_head;\ + while( tm_ptr != NULL ){\ + int length = TM_SHORT_SIZE;\ + if( GETshort_or_long_tm(tm_ptr) == SHORT_TM_CODE ){\ + length = TM_SHORT_SIZE;\ + }\ + else{\ + length = TM_LONG_SIZE;\ + }\ + /*gPC.puts("Printing Call Sign, ACK_L1, TM list");*/\ + for(int i = 0 ; i < length ; ++i){\ + /*gPC.putc(tm_ptr->TM_string[i]);*/\ + }\ + tm_ptr = tm_ptr->next_TM;\ + }\ + /*SEND call sign, ACK_L1, OBSRS TO GS*/\ + /*snd_tm.head_pointer(tm_ptr_head);*/\ + /*transmit_adf;*/\ + /*DELETE THE TM AFTER USE*/\ + tm_ptr = tm_ptr_head;\ + overflowCountExecute = 0;\ + while(tm_ptr != NULL){\ + if( overflowCountExecute < TM_OVERFLOW_CONSTANT ){\ + Base_tm *temp = tm_ptr->next_TM;\ + delete tm_ptr;\ + tm_ptr = temp;\ + ++overflowCountExecute;\ + }\ + else{\ + RESET_CDMS();\ + break;\ + }\ + }\ }\ }\ break;\ @@ -1369,7 +1455,7 @@ ++overflowCount;\ }\ else{\ - RESET_CDMS;\ + RESET_CDMS();\ break;\ }\ }\ @@ -1380,15 +1466,15 @@ if (DEBUG)\ gPC.puts("ABORTING DUE TO ABORT ON NACK\r\n");\ /*EXITED DUE TO ABORT ON NACK:*/\ - COM_TX_CNTRL = 0;\ + /*COM_TX_CNTRL = 0;*/\ RX1M.attach(&rx_read, Serial::RxIrq);\ gFLAGS = gFLAGS & (~COM_MNG_TMTC_RUNNING_FLAG);\ break;\ }\ - else if( (gFLAGS & COM_PA_HOT_FLAG) || (gFLAGS & COM_PA_OC_FLAG) ){\ + else if( gFLAGS & COM_PA_HOT_FLAG ){\ /*PA HOT: WAIT FOR TIMEOUT*/\ gCOM_PA_COOLING_TIMEOUT.attach(&after_cooling_pa, COM_PA_COOLING_TIME_LIMIT);\ - COM_TX_CNTRL = 0;\ + /*COM_TX_CNTRL = 0;*/\ RX1M.attach(&rx_read, Serial::RxIrq);\ gFLAGS = gFLAGS & (~COM_MNG_TMTC_RUNNING_FLAG);\ break;\ @@ -1401,10 +1487,9 @@ gPC.printf("completed or session timed out: %x\r\n", gMASTER_STATE);\ /*COMPLETED EXECUTION OF TC*/\ gMASTER_STATE = TCL_STATE_COMPLETED;\ - COM_POWER_OFF_TX;\ + /*COM_POWER_OFF_TX;*/\ reset_all;\ /*PENDING : ENABLE THREADS*/\ - /*gCDMS_HK_TIMER.start(5000);*/\ gPAY_SPI.bulkRead_start();\ gSESSION_TIMEOUT.detach();\ gFLAGS = gFLAGS & (~COM_MNG_TMTC_RUNNING_FLAG);\
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/COM_MNG_TMTC.h.orig Sun Jul 03 09:47:05 2016 +0000 @@ -0,0 +1,1413 @@ +// 8 Jul +// did flowchart of states + +// handle sd card with cdms team + +// Jun 6 +// WHAT IS TC exec code in L1 ack ? + +//Jan 7 +//added RLY_TMTC function +//added included related files + +//#include "Flash.h" + +DigitalIn tm_status_4m_slv(PIN39); //I2C interrupt to CDMS from BAE +//DigitalIn tm_status_4m_pl(PIN61); //I2C interrupt to CDMS from PL + +uint8_t received = 0; +uint16_t mid1; +uint16_t mid2; +uint16_t Nbytes; +uint32_t Data[2]; +uint16_t nbytes; +uint8_t flash_counter = 0; +uint16_t crc16; +uint16_t mid; +uint32_t block; + +uint8_t ACK_CODE; + +void TM_PMS_PL_SCHEDULE(Base_tm* tm_pointer1,uint8_t psc); +void ACK_L234(Base_tm* tm_pointer_short1,uint8_t ackCode,uint8_t psc); + +#define delete_TC(tc_ptr) {\ + if(tc_ptr == gHEAD_NODE_TCL){\ + gHEAD_NODE_TCL = tc_ptr->next_TC;\ + }\ + delete tc_ptr;\ +} + +// typeof tm_ptr: Base_tm +// typeof tc_ptr: Base_tc +// typeof temp_xxxx: uint8_t + + + + +#define detect_ack(tm_ptr, temp_ack) {\ + if( tm_ptr != NULL ){\ + int length = TM_SHORT_SIZE;\ + if( GETshort_or_long_tm(tm_ptr) == SHORT_TM_CODE ){\ + length = TM_SHORT_SIZE;\ + }\ + else{\ + length = TM_LONG_SIZE;\ + }\ + uint16_t crc = crc16_gen(tm_ptr->TM_string, length-2);\ + if( (((crc & 0xFF00) >> 8) == tm_ptr->TM_string[length-2]) && ( (crc & 0x00FF) == tm_ptr->TM_string[length-1] ) ){\ + uint8_t temp8;\ + temp8 = tm_ptr->TM_string[TM_ACK_CODE_INDEX];\ + temp8 = temp8 & 0xE0;\ + if( (temp8 == 0xC0) || (temp8 == 0xA0) )\ + temp_ack = 0x01;\ + else{\ + temp_ack = 0x02;\ + /*CHECK FOR NACK CODE: CRC FAIL NACK*/\ + temp8 = tm_ptr->TM_string[TM_ACK_CODE_INDEX];\ + temp8 = temp8 & 0x0F;\ + if( temp8 == CRC_FAIL_NACK_CODE ){\ + temp_ack = 0x04;\ + }\ + }\ + }\ + else\ + temp_ack = 0x03;\ + }\ + else{\ + temp_ack = 0x02;\ + }\ +} + +#define isit_obosc(tc_ptr, temp_obosc) {\ + temp_obosc = 0x00;\ + if( GETapid(tc_ptr) == APID_COM ){\ + if( ((tc_ptr->TC_string[2]) >> 4) == SERVICE_OBOSC ){\ + temp_obosc = 0x01;\ + }\ + }\ +} + +#define isit_sdcard(tc_ptr, temp_sdcard) {\ + temp_sdcard = 0x00;\ + if( GETapid(tc_ptr) == APID_COM ){\ + if( ( (tc_ptr->TC_string[2]) >> 4) == SERVICE_OBSRS ){\ + temp_sdcard = 0x01;\ + }\ + }\ +} + + + +void after_cooling_pa(){ + gCOM_MNG_TMTC_THREAD->signal_set(COM_MNG_TMTC_SIGNAL_UART_INT); +} + +/* +@brief: check for missing tc, also check crc, i.e. + if true execution can be started else have to wait + decide the next state +@param: none +@return: bool indicating whether there are missing tc +*/ +// PENDING: LAST FRAME BIT +/* +for loop: check for missing tc +if: check for incorrect sized tc +if: check for last frame bit +*/ +#define continueToExecute(returnHere) {\ + uint8_t tempReturn = 0x00;\ + /*search for missing psc*/\ + for(uint8_t p = 0x00 ; p < (gTOTAL_VALID_TC) ; ++p){\ + bool flag = false;\ + Base_tc *node_ptr = gHEAD_NODE_TCL;\ + while(node_ptr != NULL){\ + if( (GETpacket_seq_count(node_ptr) == p) && (GETcrc_pass(node_ptr) == 1) ){\ + flag = true;\ + break;\ + }\ + else{\ + node_ptr = node_ptr->next_TC;\ + }\ + }\ + if(flag == false){\ + tempReturn = 0x02;\ + break;\ + }\ + }\ + /*search for last packet bit*/\ + tempReturn = tempReturn + 0x01;\ + Base_tc *tcp = gHEAD_NODE_TCL;\ + while(tcp != NULL){\ + if(GETpacket_seq_count(tcp) == (gTOTAL_VALID_TC - 1)){\ + if( ( (tcp->TC_string[1]) & 0x20 ) == 0x20 ){\ + tempReturn = tempReturn - 0x01;\ + }\ + break;\ + }\ + tcp = tcp->next_TC;\ + }\ + returnHere = tempReturn;\ + /*UPDATE gMASTER STATE*/\ + if( (returnHere == 0x00) ){\ + if( (gMASTER_STATE == TCL_STATE_INCOMPLETE) || (gMASTER_STATE == TCL_STATE_COMPLETED) || (gMASTER_STATE == TCL_STATE_ABORTED) ){\ + gMASTER_STATE = TCL_STATE_EXECUTING;\ + }\ + }\ + else{\ + if( (gMASTER_STATE == TCL_STATE_INCOMPLETE) || (gMASTER_STATE == TCL_STATE_COMPLETED) || (gMASTER_STATE == TCL_STATE_ABORTED) ){\ + gMASTER_STATE = TCL_STATE_INCOMPLETE;\ + }\ + }\ +} + +/* +return 1 if code match +return 0 if code mismatch +*/ +#define GScodeVerification(returnHere){\ + Base_tc *testTC = gHEAD_NODE_TCL;\ + uint16_t overflowCount = 0;\ + returnHere = 0xFF;\ + while( (overflowCount < TCL_OVERFLOW_CONSTANT) && (testTC != NULL) ){\ + if( (GETpacket_seq_count(testTC) == PSC_CALLSIGN) && (GETapid(testTC) == APID_CALLSIGN) ){\ + /*uint8_t temp8 = testTC->TC_string[1];*/\ + if( true ){\ + for( int i = 2 ; i <= 8 ; ++i ){\ + if( testTC->TC_string[i] != gGSCODE[i-2] ){\ + returnHere = 0;\ + break;\ + }\ + }\ + }\ + break;\ + }\ + testTC = testTC->next_TC;\ + ++overflowCount;\ + }\ +} + +/* +@brief: DELETE THE CRC FAILED TC FROM THE LIST TO FREE-UP MEMORY AND UPDATE + THE TOTAL VALID TC AND GENERATE L1_ACK_TM +@param: none +@return: none +*/ +/*tm_ptr is the next_TM of a linked list, and should have the value NULL, i.e. tm_ptr should be the next_TM pointer of thte last node */ + +/*tm_ptr is the next_TM of a linked list, and should have the value NULL, i.e. tm_ptr should be the next_TM pointer of thte last node */ + +// CDMS TEAM CODE START +void ACK_L234(Base_tm* tm_pointer_short1,uint8_t ackCode,uint8_t psc) +{ + tm_pointer_short1->TM_string[0] = 0xB0; + tm_pointer_short1->TM_string[1] = psc; + tm_pointer_short1->TM_string[2] = ackCode; + tm_pointer_short1->TM_string[3] = 0x00; + tm_pointer_short1->TM_string[4] = 0x00; + for(uint8_t i=0;i<6;i++) + tm_pointer_short1->TM_string[i+5] = 0; + crc16 = crc16_gen(tm_pointer_short1->TM_string,11); + tm_pointer_short1->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8); + tm_pointer_short1->TM_string[12] = (uint8_t)(crc16&0x00FF); + tm_pointer_short1->next_TM = NULL; +} +void TM_PMS_PL_SCHEDULE(Base_tm *tm_pointer1,uint8_t psc) +{ + Base_tm *tm_pointer2 = NULL; + if(!(tm_pointer2 = new Long_tm)) + { + gPC.printf("\n\rError: out of memory"); + return; + } + Base_tm *tm_pointer3 = NULL; + if(!(tm_pointer3 = new Long_tm)) + { + gPC.printf("\n\rError: out of memory"); + return; + } + Base_tm *tm_pointer4 = NULL; + if(!(tm_pointer4 = new Long_tm)) + { + gPC.printf("\n\rError: out of memory"); + return; + } + Base_tm *tm_pointer5 = NULL; + if(!(tm_pointer5 = new Long_tm)) + { + gPC.printf("\n\rError: out of memory"); + return; + } + Base_tm *tm_pointer6 = NULL; + if(!(tm_pointer6 = new Long_tm)) + { + gPC.printf("\n\rError: out of memory"); + return; + } + tm_pointer1->TM_string[0] = 0x48; + tm_pointer1->TM_string[1] = psc; + tm_pointer1->TM_string[2] = 0xA0; + tm_pointer1->TM_string[3] = 0x01; + for(uint8_t i=0;i<128;i+=4) + { + tm_pointer1->TM_string[i+4] = (uint8_t)((pl_block[i/4] & 0xFF000000)>>24); + tm_pointer1->TM_string[i+5] = (uint8_t)((pl_block[i/4] & 0x00FF0000)>>16); + tm_pointer1->TM_string[i+6] = (uint8_t)((pl_block[i/4] & 0x0000FF00)>>8); + tm_pointer1->TM_string[i+7] = (uint8_t)((pl_block[i/4] & 0x000000FF)); + } + crc16 = crc16_gen(tm_pointer1->TM_string,132); + tm_pointer1->TM_string[132] = (uint8_t)((crc16&0xFF00)>>8); + tm_pointer1->TM_string[133] = (uint8_t)(crc16&0x00FF); + tm_pointer1->next_TM = tm_pointer2; + + tm_pointer2->TM_string[0] = 0x48; + tm_pointer2->TM_string[1] = psc; + tm_pointer2->TM_string[2] = 0xA0; + tm_pointer2->TM_string[3] = 0x02; + for(uint8_t i=0;i<128;i+=4) + { + tm_pointer2->TM_string[i+4] = (uint8_t)((pl_block[(i/4)+32] & 0xFF000000)>>24); + tm_pointer2->TM_string[i+5] = (uint8_t)((pl_block[(i/4)+32] & 0x00FF0000)>>16); + tm_pointer2->TM_string[i+6] = (uint8_t)((pl_block[(i/4)+32] & 0x0000FF00)>>8); + tm_pointer2->TM_string[i+7] = (uint8_t)((pl_block[(i/4)+32] & 0x000000FF)); + } + crc16 = crc16_gen(tm_pointer2->TM_string,132); + tm_pointer2->TM_string[132] = (uint8_t)((crc16&0xFF00)>>8); + tm_pointer2->TM_string[133] = (uint8_t)(crc16&0x00FF); + tm_pointer2->next_TM = tm_pointer3; + + tm_pointer3->TM_string[0] = 0x48; + tm_pointer3->TM_string[1] = psc; + tm_pointer3->TM_string[2] = 0xA0; + tm_pointer3->TM_string[3] = 0x03; + for(uint8_t i=0;i<128;i+=4) + { + tm_pointer3->TM_string[i+4] = (uint8_t)((pl_block[(i/4)+64] & 0xFF000000)>>24); + tm_pointer3->TM_string[i+5] = (uint8_t)((pl_block[(i/4)+64] & 0x00FF0000)>>16); + tm_pointer3->TM_string[i+6] = (uint8_t)((pl_block[(i/4)+64] & 0x0000FF00)>>8); + tm_pointer3->TM_string[i+7] = (uint8_t)((pl_block[(i/4)+64] & 0x000000FF)); + } + crc16 = crc16_gen(tm_pointer3->TM_string,132); + tm_pointer3->TM_string[132] = (uint8_t)((crc16&0xFF00)>>8); + tm_pointer3->TM_string[133] = (uint8_t)(crc16&0x00FF); + tm_pointer3->next_TM = tm_pointer4; + + tm_pointer4->TM_string[0] = 0x48; + tm_pointer4->TM_string[1] = psc; + tm_pointer4->TM_string[2] = 0xA0; + tm_pointer4->TM_string[3] = 0x04; + for(uint8_t i=0;i<128;i+=4) + { + tm_pointer4->TM_string[i+4] = (uint8_t)((pl_block[(i/4)+96] & 0xFF000000)>>24); + tm_pointer4->TM_string[i+5] = (uint8_t)((pl_block[(i/4)+96] & 0x00FF0000)>>16); + tm_pointer4->TM_string[i+6] = (uint8_t)((pl_block[(i/4)+96] & 0x0000FF00)>>8); + tm_pointer4->TM_string[i+7] = (uint8_t)((pl_block[(i/4)+96] & 0x000000FF)); + } + crc16 = crc16_gen(tm_pointer4->TM_string,132); + tm_pointer4->TM_string[132] = (uint8_t)((crc16&0xFF00)>>8); + tm_pointer4->TM_string[133] = (uint8_t)(crc16&0x00FF); + tm_pointer4->next_TM = tm_pointer5; + + tm_pointer5->TM_string[0] = 0x48; + tm_pointer5->TM_string[1] = psc; + tm_pointer5->TM_string[2] = 0xA0; + tm_pointer5->TM_string[3] = 0x05; + for(uint8_t i=0;i<128;i+=4) + { + tm_pointer5->TM_string[i+4] = (uint8_t)((pl_block[(i/4)+128] & 0xFF000000)>>24); + tm_pointer5->TM_string[i+5] = (uint8_t)((pl_block[(i/4)+128] & 0x00FF0000)>>16); + tm_pointer5->TM_string[i+6] = (uint8_t)((pl_block[(i/4)+128] & 0x0000FF00)>>8); + tm_pointer5->TM_string[i+7] = (uint8_t)((pl_block[(i/4)+128] & 0x000000FF)); + } + crc16 = crc16_gen(tm_pointer5->TM_string,132); + tm_pointer5->TM_string[132] = (uint8_t)((crc16&0xFF00)>>8); + tm_pointer5->TM_string[133] = (uint8_t)(crc16&0x00FF); + tm_pointer5->next_TM = tm_pointer6; + + tm_pointer6->TM_string[0] = 0x48; + tm_pointer6->TM_string[1] = psc; + tm_pointer6->TM_string[2] = 0xA0; + tm_pointer6->TM_string[3] = 0x06; + for(uint8_t i=0;i<128;i+=4) + { + tm_pointer6->TM_string[i+4] = (uint8_t)((pl_block[(i/4)+160] & 0xFF000000)>>24); + tm_pointer6->TM_string[i+5] = (uint8_t)((pl_block[(i/4)+160] & 0x00FF0000)>>16); + tm_pointer6->TM_string[i+6] = (uint8_t)((pl_block[(i/4)+160] & 0x0000FF00)>>8); + tm_pointer6->TM_string[i+7] = (uint8_t)((pl_block[(i/4)+160] & 0x000000FF)); + } + crc16 = crc16_gen(tm_pointer6->TM_string,132); + tm_pointer6->TM_string[132] = (uint8_t)((crc16&0xFF00)>>8); + tm_pointer6->TM_string[133] = (uint8_t)(crc16&0x00FF); + tm_pointer6->next_TM = NULL; +} +Base_tm* FCTN_CDMS_RLY_TMTC(Base_tc *tc_ptr) +{ + //uint8_t ACKCODE = 0xB0; + bool y; + //gPC.printf("\rTC execution in progress\r\n"); + Base_tm *tm_pointer = new Long_tm; + Base_tm *tm_ptr = tm_pointer; + //Base_tm *tm_ptr = new Long_tm; + Base_tm *tm_pointer_short = new Short_tm; + Base_tm *tm_ptr_short = tm_pointer_short; + received = 0; + switch(GETapid(tc_ptr)) //checking APID's + { + case 1: //apid=01 implies it corresponds to bae + { + BAE_I2C_mutex.lock(); + gPC.printf("Telecommand is for BAE\r\n"); + gPC.printf("Sending TC to BAE...\r\n"); //interrupt to be sent to the bae + y = FCTN_I2C_WRITE((char*)tc_ptr->TC_string,TC_LONG_SIZE); // Check for SHORT and LONG TC and then send + + if(y==1) + { + ACK_L234(tm_ptr_short,0x03,GETpacket_seq_count(tc_ptr)); + return tm_ptr_short; + } + else if(y==0) + { + //wait(0.2); + uint8_t poll=0; + while(poll<60 && BAE_I2C_GPIO==0) + { + wait_ms(50); + poll+=1; + } + if(BAE_I2C_GPIO == 1) //name to be changed later + { + gPC.printf("BAE_I2C_GPIO is high\r\n"); + + y=FCTN_I2C_READ((char*)tm_pointer->TM_string,TM_LONG_SIZE); //rify later about the size + if(y==0) + { + tm_pointer->next_TM=NULL; + return tm_ptr; + } + else if(y==1) + { + ACK_L234(tm_ptr_short,0x85,GETpacket_seq_count(tc_ptr)); + //gPC.printf("\n\rPTE->PDIR = 0x%08X",PTE->PDIR); + return tm_ptr_short; + break; + } + } + else if(BAE_I2C_GPIO == 0) //name to be changed later + { + gPC.printf("BAE_I2C_GPIO is not high\r\n"); + ACK_L234(tm_ptr_short,0x84,GETpacket_seq_count(tc_ptr)); + return tm_ptr_short; + } + } + BAE_I2C_mutex.unlock(); + } + + case 2: // APID = 2 corresponds to CDMS + { + //gPC.printf("Telecommand is for CDMS\r\n"); //apid = 10 corresponds to cdms + switch(GETservice_type(tc_ptr)) + { + /*case 0x60: //service type = 0x6 + { + gPC.printf("service:MMS\r\n"); + switch(GETservice_subtype(tc_ptr)) + { + case 0x2: //service subtye + { + //gPC.printf("sub_service:Read LONG_RAM_Memory\r\n"); + mid=((uint16_t)(tc_ptr->TC_string[3]<<4))+((uint16_t)(tc_ptr->TC_string[4])); + if(mid!=0x0000 && mid!=0x0001) + { + ACK_L234(tm_ptr_short,0x02,GETpacket_seq_count(tc_ptr)); + return tm_ptr_short; + } + FCTN_CDMS_RD_L_RAM(tm_pointer); + + tm_pointer->TM_string[0] = 0x30; + tm_pointer->TM_string[1] = GETpacket_seq_count(tc_ptr); + tm_pointer->TM_string[2] = 0xA0; + tm_pointer->TM_string[3] = 0x00; //spare bits + + crc16 = crc16_gen(tm_ptr->TM_string,132); + tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8); + tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF); + tm_pointer->next_TM = NULL; + return tm_ptr; + } + case 0x5: // change the cases appropriately + { + //gPC.printf("WRITE ON SHORT_FLASH_MEMORY\r\n"); + mid=(uint16_t)(tc_ptr->TC_string[3]<<4)+(uint16_t)(tc_ptr->TC_string[4]); + //32 bits at a time + + if(mid!= && mid!=) //allowable MID values? + { + ACK_L234(tm_ptr_short,0x02,GETpacket_seq_count(tc_ptr)); + return tm_ptr_short; + } + + FCTN_CDMS_WR_S_FLASH(tc_ptr); + + ACK_L234(tm_ptr_short,???,GETpacket_seq_count(tc_ptr)); //ackCode = ? for success + + return tm_ptr_short; + } + case 0x6: + { + //gPC.printf("WRITE ON LONG_FLASH_MEMORY\r\n"); + mid=(uint16_t)(tc_ptr->TC_string[3]<<4)+(uint16_t)(tc_ptr->TC_string[4]); + //1024 bits at a time + + if(mid<0x0002 || mid>0x000A) //allowable MID values? + { + ACK_L234(tm_ptr_short,0x02,GETpacket_seq_count(tc_ptr)); //ackCode = ? for invalid mid + return tm_ptr_short; + } + + ///Send TM for success after writing onto flash + FCTN_CDMS_WR_L_FLASH(mid); + + return tm_ptr_short; + } + default: + { + gPC.printf("INVALID SERVICE SUBTYPE\r\n"); + ACK_L234(tm_ptr_short,0x02,GETpacket_seq_count(tc_ptr)); + return tm_ptr_short; + } + } + } */ + case 0x80: + { + gPC.printf("service:FUNCTION MANAGEMENT SERVICE\r\n"); + if(GETservice_subtype(tc_ptr)==0x1) + { + if(GETpid(tc_ptr)==0x01) + { + if(CDMS_STANDBY==1) + { + //gPC.printf("TC_PL_INIT\r\n"); // call PWR_SWCH_ON function + + P_PL_INIT(); + + ACK_L234(tm_ptr_short,0xC0,GETpacket_seq_count(tc_ptr)); + return tm_ptr_short; + } + else if(CDMS_STANDBY==0) + { + ACK_L234(tm_ptr_short,0x87,GETpacket_seq_count(tc_ptr)); //TC cannot be processed now + return tm_ptr_short; + } + } + else if(GETpid(tc_ptr)==0x02) + { + if(CDMS_STANDBY==1) + { + //gPC.printf("TC_PL_MAIN\r\n"); // call PWR_SWCH_ON function + + P_PL_MAIN(); + + ACK_L234(tm_ptr_short,0xC0,GETpacket_seq_count(tc_ptr)); + return tm_ptr_short; + } + else if(CDMS_STANDBY==0) + { + ACK_L234(tm_ptr_short,0x87,GETpacket_seq_count(tc_ptr)); //TC cannot be processed now + return tm_ptr_short; + } + } + else if(GETpid(tc_ptr)==0x03) + { + if(CDMS_STANDBY==1) + { + //gPC.printf("PL_COM_INIT\r\n"); // call PWR_SWCH_ON function + + P_COM_INIT(); + + ACK_L234(tm_ptr_short,0xC0,GETpacket_seq_count(tc_ptr)); + return tm_ptr_short; + } + else if(CDMS_STANDBY==0) + { + ACK_L234(tm_ptr_short,0x87,GETpacket_seq_count(tc_ptr)); //TC cannot be processed now + return tm_ptr_short; + } + } + else if(GETpid(tc_ptr)==0x04) + { + if(CDMS_STANDBY==1) + { + //gPC.printf("TC_P_CDMS_HK_MAIN\r\n"); // call PWR_SWCH_ON function + + P_CDMS_HK_MAIN(); + + ACK_L234(tm_ptr_short,0xC0,GETpacket_seq_count(tc_ptr)); + return tm_ptr_short; + } + else if(CDMS_STANDBY==0) + { + ACK_L234(tm_ptr_short,0x87,GETpacket_seq_count(tc_ptr)); //TC cannot be processed now + return tm_ptr_short; + } + } + else if(GETpid(tc_ptr)==0x05) + { + if(CDMS_STANDBY==1) + { + //gPC.printf("TC_SW_ON_SD\r\n"); // call PWR_SWCH_ON function + + P_PL_RCV_SC_DATA(); + + ACK_L234(tm_ptr_short,0xC0,GETpacket_seq_count(tc_ptr)); + return tm_ptr_short; + } + else if(CDMS_STANDBY==0) + { + ACK_L234(tm_ptr_short,0x87,GETpacket_seq_count(tc_ptr)); //TC cannot be processed now + return tm_ptr_short; + } + } + else if(GETpid(tc_ptr)==0x06) + { + if(CDMS_STANDBY==1) + { + //gPC.printf("TC_SW_ON_RTC\r\n"); // call PWR_SWCH_ON function + + P_CDMS_INIT_SD(); + + ACK_L234(tm_ptr_short,0xC0,GETpacket_seq_count(tc_ptr)); + return tm_ptr_short; + } + else if(CDMS_STANDBY==0) + { + ACK_L234(tm_ptr_short,0x87,GETpacket_seq_count(tc_ptr)); //TC cannot be processed now + return tm_ptr_short; + } + } + else if(GETpid(tc_ptr)==0x11) + { + //gPC.printf("TC_SW_ON_SD\r\n"); // call PWR_SWCH_ON function + + CDMS_SD_SW_ON(); + + ACK_L234(tm_ptr_short,0xC0,GETpacket_seq_count(tc_ptr)); + return tm_ptr_short; + } + else if(GETpid(tc_ptr)==0x21) + { + //gPC.printf("TC_SW_ON_SD\r\n"); // call PWR_SWCH_ON function + + CDMS_SD_SW_OFF(); + + ACK_L234(tm_ptr_short,0xC0,GETpacket_seq_count(tc_ptr)); + return tm_ptr_short; + } + else if(GETpid(tc_ptr)==0x13) + { + //gPC.printf("TC_SW_ON_BAE\r\n"); // call PWR_SWCH_ON function + + SW_ON_BAE(); + + ACK_L234(tm_ptr_short,0xC0,GETpacket_seq_count(tc_ptr)); + return tm_ptr_short; + } + else if(GETpid(tc_ptr)==0x23) + { + //gPC.printf("TC_SW_OFF_BAE\r\n"); // call PWR_SWCH_ON function + + SW_OFF_BAE(); + + ACK_L234(tm_ptr_short,0xC0,GETpacket_seq_count(tc_ptr)); + return tm_ptr_short; + } + else if(GETpid(tc_ptr)==0x14) + { + //gPC.printf("TC_SW_ON_PL_BEE\r\n"); // call PWR_SWCH_ON function + + SW_ON_PL_BEE(); + + ACK_L234(tm_ptr_short,0xC0,GETpacket_seq_count(tc_ptr)); + return tm_ptr_short; + } + else if(GETpid(tc_ptr)==0x24) + { + //gPC.printf("TC_SW_OFF_PL_BEE\r\n"); // call PWR_SWCH_ON function + + SW_OFF_PL_BEE(); + + ACK_L234(tm_ptr_short,0xC0,GETpacket_seq_count(tc_ptr)); + return tm_ptr_short; + } + else if(GETpid(tc_ptr)==0x15) + { + //gPC.printf("TC_SW_ON_PL_EPS\r\n"); // call PWR_SWCH_ON function + + SW_ON_PL_EPS(); + + ACK_L234(tm_ptr_short,0xC0,GETpacket_seq_count(tc_ptr)); + return tm_ptr_short; + } + else if(GETpid(tc_ptr)==0x25) + { + //gPC.printf("TC_SW_OFF_PL_EPS\r\n"); // call PWR_SWCH_ON function + + SW_OFF_PL_EPS(); + + ACK_L234(tm_ptr_short,0xC0,GETpacket_seq_count(tc_ptr)); + return tm_ptr_short; + } + else if(GETpid(tc_ptr)==0x16) + { + + //gPC.printf("TC_SW_ON_V_A_EN\r\n"); // call PWR_SWCH_ON function + + SW_ON_V_A_EN(); + + ACK_L234(tm_ptr_short,0xC0,GETpacket_seq_count(tc_ptr)); + return tm_ptr_short; + } + else if(GETpid(tc_ptr)==0x26) + { + //gPC.printf("TC_SW_OFF_V_A_EN\r\n"); // call PWR_SWCH_ON function + + SW_OFF_V_A_EN(); + + ACK_L234(tm_ptr_short,0xC0,GETpacket_seq_count(tc_ptr)); + return tm_ptr_short; + } + else if(GETpid(tc_ptr)==0x31) + { + //gPC.printf("TC_RST_SD\r\n"); // call PWR_SWCH_ON function + + RST_SD(); + + ACK_L234(tm_ptr_short,0xC0,GETpacket_seq_count(tc_ptr)); + return tm_ptr_short; + } + else if(GETpid(tc_ptr)==0x33) + { + //gPC.printf("TC_RST_BAE\r\n"); // call PWR_SWCH_ON function + + RST_BAE(); + + ACK_L234(tm_ptr_short,0xC0,GETpacket_seq_count(tc_ptr)); + return tm_ptr_short; + } + else if(GETpid(tc_ptr)==0x34) + { + //gPC.printf("TC_RST_PL_BEE\r\n"); // call PWR_SWCH_ON function + + RST_PL_BEE(); + + ACK_L234(tm_ptr_short,0xC0,GETpacket_seq_count(tc_ptr)); + return tm_ptr_short; + } + else if(GETpid(tc_ptr)==0x38) + { + //gPC.printf() + + CDMS_INTERNAL_RESET(); + ACK_L234(tm_ptr_short,0xC0,GETpacket_seq_count(tc_ptr)); + } + else if(GETpid(tc_ptr)==0x40) + { + //gPC.printf("RESET_HK_COUNTER\r\n"); // call PWR_SWCH_ON function + + RST_HK_COUNTER(); + + ACK_L234(tm_ptr_short,0xC0,GETpacket_seq_count(tc_ptr)); + return tm_ptr_short; + } + else if(GETpid(tc_ptr)==0x41) + { + //gPC.printf("RESET_HK_COUNTER\r\n"); // call PWR_SWCH_ON function + + RST_HK_COUNTER(); + + ACK_L234(tm_ptr_short,0xC0,GETpacket_seq_count(tc_ptr)); + return tm_ptr_short; + } + else if(GETpid(tc_ptr)==0xF1) + { + //gPC.printf("TC_CDMS_RD_RTC\r\n"); // call PWR_SWCH_ON function + + /*uint32_t time_temp = FCTN_CDMS_RD_RTC(); //RTC_RD_EROR has to incorporated + tm_pointer->TM_string[0] = 0x78; + tm_pointer->TM_string[1] = GETpacket_seq_count(tc_ptr); + tm_pointer->TM_string[2] = 0xA0; + tm_pointer->TM_string[3] = 0x00; + tm_pointer->TM_string[4] = (uint8_t)((time & 0xFF000000)>>24); + tm_pointer->TM_string[5] = (uint8_t)((time & 0x00FF0000)>>16); + tm_pointer->TM_string[6] = (uint8_t)((time & 0x0000FF00)>>8); + tm_pointer->TM_string[7] = (uint8_t)((time & 0x000000FF)); + for(uint8_t i=0;i<124;i++) + { + tm_pointer->TM_string[i+8] = 0x00; + } + crc16 = crc16_gen(tm_ptr->TM_string,132); + tm_pointer->TM_string[132] = (uint8_t)((crc16&0xFF00)>>8); + tm_pointer->TM_string[133] = (uint8_t)(crc16&0x00FF); + tm_pointer->next_TM = NULL; + return tm_ptr; */ //incomplete + } + else if(GETpid(tc_ptr)==0xF0) + { + uint8_t statusbits[64]; + CDMS_RD_SD_HK(statusbits); + ACK_L234(tm_ptr_short,0xC0,GETpacket_seq_count(tc_ptr)); + } + else + { + gPC.printf("INVALID FID\r\n"); + ACK_L234(tm_ptr_short,0x02,GETpacket_seq_count(tc_ptr)); + return tm_ptr_short; + } + } + else + { + gPC.printf("INVALID SERVICE SUBTYPE\r\n"); + ACK_L234(tm_ptr_short,0x02,GETpacket_seq_count(tc_ptr)); + return tm_ptr_short; + } + } + case 0x70: + { + gPC.printf("\n\n\rService:PAYLOAD MANAGEMENT SERVICE"); + if(GETservice_subtype(tc_ptr)==0x1) //make sure it is LONG TC before executing else INVALID TC + { + gPC.printf("\n\rTC with subtype = 0x1"); + TM_PMS_PL_SCHEDULE(tm_ptr,GETpacket_seq_count(tc_ptr)); + for(uint8_t i=0,j=0;i<32;i++) + { + pl_block[i] &= 0x00000000; + pl_block[i] |= (((uint32_t)(tc_ptr->TC_string[3+j]))<<24); + pl_block[i] |= (((uint32_t)(tc_ptr->TC_string[4+j]))<<16); + pl_block[i] |= (((uint32_t)(tc_ptr->TC_string[5+j]))<<8); + pl_block[i] |= (((uint32_t)(tc_ptr->TC_string[6+j]))); + j+=4; + } + return tm_ptr; + } + else if(GETservice_subtype(tc_ptr)==0x2) + { + gPC.printf("\n\rTC with subtype = 0x2"); + TM_PMS_PL_SCHEDULE(tm_ptr,GETpacket_seq_count(tc_ptr)); + for(uint8_t i=32,j=0;i<64;i++,j+=4) + { + pl_block[i] &= 0x00000000; + pl_block[i] |= (((uint32_t)(tc_ptr->TC_string[3+j]))<<24); + pl_block[i] |= (((uint32_t)(tc_ptr->TC_string[4+j]))<<16); + pl_block[i] |= (((uint32_t)(tc_ptr->TC_string[5+j]))<<8); + pl_block[i] |= (((uint32_t)(tc_ptr->TC_string[6+j]))); + } + return tm_ptr; + } + else if(GETservice_subtype(tc_ptr)==0x3) + { + gPC.printf("\n\rTC with subtype = 0x3"); + TM_PMS_PL_SCHEDULE(tm_ptr,GETpacket_seq_count(tc_ptr)); + for(uint8_t i=64,j=0;i<96;i++,j+=4) + { + pl_block[i] &= 0x00000000; + pl_block[i] |= (((uint32_t)(tc_ptr->TC_string[3+j]))<<24); + pl_block[i] |= (((uint32_t)(tc_ptr->TC_string[4+j]))<<16); + pl_block[i] |= (((uint32_t)(tc_ptr->TC_string[5+j]))<<8); + pl_block[i] |= (((uint32_t)(tc_ptr->TC_string[6+j]))); + } + return tm_ptr; + } + else if(GETservice_subtype(tc_ptr)==0x4) + { + gPC.printf("\n\rTC with subtype = 0x4"); + TM_PMS_PL_SCHEDULE(tm_ptr,GETpacket_seq_count(tc_ptr)); + for(uint8_t i=96,j=0;i<128;i++,j+=4) + { + pl_block[i] &= 0x00000000; + pl_block[i] |= (((uint32_t)(tc_ptr->TC_string[3+j]))<<24); + pl_block[i] |= (((uint32_t)(tc_ptr->TC_string[4+j]))<<16); + pl_block[i] |= (((uint32_t)(tc_ptr->TC_string[5+j]))<<8); + pl_block[i] |= (((uint32_t)(tc_ptr->TC_string[6+j]))); + } + return tm_ptr; + } + else if(GETservice_subtype(tc_ptr)==0x5) + { + gPC.printf("\n\rTC with subtype = 0x5"); + TM_PMS_PL_SCHEDULE(tm_ptr,GETpacket_seq_count(tc_ptr)); + for(uint8_t i=128,j=0;i<160;i++,j+=4) + { + pl_block[i] &= 0x00000000; + pl_block[i] |= (((uint32_t)(tc_ptr->TC_string[3+j]))<<24); + pl_block[i] |= (((uint32_t)(tc_ptr->TC_string[4+j]))<<16); + pl_block[i] |= (((uint32_t)(tc_ptr->TC_string[5+j]))<<8); + pl_block[i] |= (((uint32_t)(tc_ptr->TC_string[6+j]))); + } + return tm_ptr; + } + else if(GETservice_subtype(tc_ptr)==0x6) + { + gPC.printf("\n\rTC with subtype = 0x6"); + TM_PMS_PL_SCHEDULE(tm_ptr,GETpacket_seq_count(tc_ptr)); + for(uint8_t i=160,j=0;i<192;i++,j+=4) + { + pl_block[i] &= 0x00000000; + pl_block[i] |= (((uint32_t)(tc_ptr->TC_string[3+j]))<<24); + pl_block[i] |= (((uint32_t)(tc_ptr->TC_string[4+j]))<<16); + pl_block[i] |= (((uint32_t)(tc_ptr->TC_string[5+j]))<<8); + pl_block[i] |= (((uint32_t)(tc_ptr->TC_string[6+j]))); + } + return tm_ptr; + } + else if(GETservice_subtype(tc_ptr)==0xF) + { + gPC.printf("\n\rTC with subtype = 0xF"); + TM_PMS_PL_SCHEDULE(tm_ptr,GETpacket_seq_count(tc_ptr)); + return tm_ptr; + } + else + { + gPC.printf("INVALID SERVICE SUBTYPE\r\n"); + ACK_L234(tm_ptr_short,0x02,GETpacket_seq_count(tc_ptr)); + return tm_ptr_short; + } + } + default: + { + gPC.printf("ILLEGAL TC"); + ACK_L234(tm_ptr_short,0x02,GETpacket_seq_count(tc_ptr)); + return tm_ptr_short; + } + } + } + case 3: + { + //#if DEBUG + gPC.printf("\n\rTelecommand is for PL\r\n"); + //#endif + if(GETshort_or_long_tc(tc_ptr) == LONG_TC_CODE) + y=FCTN_I2C_WRITE_PL((char*)tc_ptr->TC_string,TC_LONG_SIZE); + else if(GETshort_or_long_tc(tc_ptr) == SHORT_TC_CODE) + y=FCTN_I2C_WRITE_PL((char*)tc_ptr->TC_string,TC_SHORT_SIZE); + + if(y==1) + { + ACK_L234(tm_ptr_short,0x03,GETpacket_seq_count(tc_ptr)); + return tm_ptr_short; + break; + } + else if(y==0) + { + //wait(0.2); + uint8_t poll=0; + while(poll<60 && PL_I2C_Intr==0) + { + wait_ms(50); + poll+=1; + } + if(PL_I2C_Intr == 1) //name to be changed later + { + gPC.printf("PL_I2C_Intr is high\r\n"); + + y=FCTN_I2C_READ_PL((char*)tm_pointer->TM_string,TM_LONG_SIZE); //rify later about the size + if(y==0) + { + tm_pointer->next_TM=NULL; + return tm_ptr; + break; + } + else if(y==1) + { + ACK_L234(tm_ptr_short,0x85,GETpacket_seq_count(tc_ptr)); + //gPC.printf("\n\rPTE->PDIR = 0x%08X",PTE->PDIR); + return tm_ptr_short; + break; + } + } + else if(PL_I2C_Intr == 0) //name to be changed later + { + gPC.printf("PL_I2C_Intr is not high\r\n"); + ACK_L234(tm_ptr_short,0x84,GETpacket_seq_count(tc_ptr)); + return tm_ptr_short; + } + } + } + default: //invalid TC + { + gPC.printf("INVALID TC\r\n"); + ACK_L234(tm_ptr_short,0x02,GETpacket_seq_count(tc_ptr)); + return tm_ptr_short; + } + } + return; +} +// CDMS TEAM CODE END + +// EXECUTE OBOSC +#define execute_obosc_core(tc_ptr, tm_ptr, reset_flag) {\ + if (DEBUG)\ + gPC.puts("Inside execute_obosc_core\r\n");\ + uint8_t service_subtype = (tc_ptr->TC_string[2]) & 0x0F;\ + uint8_t temp8 = 0x00;\ + Base_tc *modify_this = gHEAD_NODE_TCL;\ + int modify_overflow = 0x00;\ + switch( service_subtype ){\ + case OBOSC_SUB_DISABLE:\ + /*gPC.puts("target psc are ");*/\ + for(int i = 3 ; i < 9 ; ++i){\ + /*gPC.printf("%u ", tc_ptr->TC_string[i]);*/\ + }\ + /*gPC.puts("\r\n");*/\ + /*gPC.puts("disable type obosc\r\n");*/\ + while( modify_this != NULL ){\ + if( modify_overflow < TCL_OVERFLOW_CONSTANT ){\ + uint8_t modify_psc = GETpacket_seq_count(modify_this);\ + /*gPC.printf("mosify_psc = %u\r\n", modify_psc);*/\ + for( int i = 3 ; i < 9 ; ++i ){\ + uint8_t target_psc = tc_ptr->TC_string[i];\ + if( (target_psc == modify_psc) && (target_psc != 0) ){\ + uint16_t tempExec = TC_STATE_DISABLED;\ + PUTexec_status( modify_this, tempExec );\ + break;\ + }\ + }\ + modify_this = modify_this->next_TC;\ + ++modify_overflow;\ + }\ + else{\ + RESET_CDMS;\ + break;\ + }\ + }\ + break;\ + case OBOSC_SUB_RETRY:\ + /*gPC.puts("retry type obosc\r\n");*/\ + while( modify_this != NULL ){\ + if( modify_overflow < TCL_OVERFLOW_CONSTANT ){\ + uint8_t modify_psc = GETpacket_seq_count(modify_this);\ + for( int i = 3 ; i < 9 ; ++i ){\ + uint8_t target_psc = tc_ptr->TC_string[i];\ + if( (target_psc == modify_psc) && (target_psc != 0) ){\ + uint16_t tempExec = TC_STATE_MARKED_RETRY;\ + PUTexec_status( modify_this, tempExec );\ + /*gPC.puts("reqquired tc found: disable\r\n");*/\ + break;\ + }\ + }\ + modify_this = modify_this->next_TC;\ + ++modify_overflow;\ + }\ + else{\ + RESET_CDMS;\ + break;\ + }\ + }\ + break;\ + }\ + Base_tm *ackl234new = new Short_tm;\ + ackl234new->next_TM = NULL;\ + /*return telemetry pointer here*/\ + tm_ptr = ackl234new;\ + ackl234new->TM_string[0] = TMID_ACK_L234 << 4;\ + ackl234new->TM_string[1] = GETpacket_seq_count(tc_ptr);\ + ackl234new->TM_string[2] = 0xA0;\ + for(int i = 3; i < 11; ++i){\ + ackl234new->TM_string[i] = 0x00;\ + }\ + uint16_t crc = crc16_gen(ackl234new->TM_string, TM_SHORT_SIZE-2);\ + ackl234new->TM_string[11] = (crc & 0xFF00) >> 8;\ + ackl234new->TM_string[12] = crc & 0x00FF;\ + /*ack l234 old*/\ + if( service_subtype == OBOSC_SUB_REP_LE ){\ + if( gLAST_TM_SHORT_OR_LONG == SHORT_TM_CODE ){\ + Base_tm *ackl234old = new Short_tm;\ + ackl234old->next_TM = NULL;\ + /*APPEND TO ACK L234 NEW HERE*/\ + ackl234new->next_TM = ackl234old;\ + for( int i = 0 ; i < TM_SHORT_SIZE ; ++i ){\ + ackl234old->TM_string[i] = gLAST_TM[i];\ + }\ + }\ + else{\ + Base_tm *tempLongTM = new Long_tm;\ + tempLongTM->next_TM = NULL;\ + /*APPEND TO ACK L234 NEW HERE*/\ + ackl234new->next_TM = tempLongTM;\ + for( int i = 0 ; i < TM_LONG_SIZE ; ++i ){\ + tempLongTM->TM_string[i] = gLAST_TM[i];\ + }\ + }\ + }\ + else if( service_subtype == OBOSC_SUB_REP_TCLD ){\ + get_tc_list(ackl234new->next_TM, GETpacket_seq_count(tc_ptr));\ + }\ + else if( service_subtype == OBOSC_SUB_RESET ){\ + reset_flag = 1;\ + }\ + else if( (service_subtype != OBOSC_SUB_DISABLE) && (service_subtype != OBOSC_SUB_RETRY) ){\ + /*CHANGE THE ACK CODE TO INVALID TC*/\ + ackl234new->TM_string[2] = 0xAF;\ + }\ + if (DEBUG)\ + gPC.puts("completed obosc\r\n");\ +} + +/*tm_ptr is the next_TM of a linked list, and should have the value NULL, i.e. tm_ptr should be the next_TM pointer of thte last node */ + + +#define EXECUTE_OBOSC_ONLY {\ + gMASTER_STATE = TCL_STATE_EXECUTING;\ + int reset_flag = 0;\ + if (DEBUG)\ + gPC.puts("iNSIDE EXECUTE_OBOSC_ONLY\r\n");\ + Base_tm *obosc_tm_core = NULL;\ + Base_tm *obosc_tm = obosc_tm_core;\ + for(uint8_t execute_psc = PSC_START_VALUE ; execute_psc < gTOTAL_VALID_TC ; ++execute_psc){\ + Base_tc* current_TC = gHEAD_NODE_TCL;\ + int overCount = 0;\ + while( current_TC != NULL ){\ + if( overCount < TCL_OVERFLOW_CONSTANT ){\ + if( (GETcrc_pass(current_TC) == 1) && (GETpacket_seq_count(current_TC) == execute_psc) ){\ + /*CHECK FOR OBOSC*/\ + uint8_t temp82 = 0x00;\ + isit_obosc(current_TC, temp82);\ + if(temp82 == 0x01){\ + uint16_t current_exec_status = GETexec_status(current_TC);\ + if( (current_exec_status == TC_STATE_SUCCESSFULLY_EXECUTED) || (current_exec_status == TC_STATE_DISABLED) )\ + break;\ + else if( (current_exec_status == TC_STATE_UNEXECUTED) || (current_exec_status == TC_STATE_MARKED_RETRY) ){\ + if (DEBUG)\ + gPC.printf("It is obosc: %u\r\n", execute_psc);\ + /*EXECUTION OF OBOSC TC*/\ + /*WARNING: LARGE MEMORY UTILIZATION FOR TC-LIST-REPORT */\ + execute_obosc_core(current_TC, obosc_tm_core, reset_flag);\ + Base_tm *obosc_tm_current = obosc_tm_core;\ + while(obosc_tm_core != NULL){\ + obosc_tm_core = obosc_tm_core->next_TM;\ + }\ + if(obosc_tm_current->TM_string[2] == 0xA0){\ + uint16_t temp16 = TC_STATE_SUCCESSFULLY_EXECUTED;\ + PUTexec_status(current_TC, temp16);\ + }\ + else{\ + uint16_t temp16 = TC_STATE_EXECUTION_FAILED;\ + PUTexec_status(current_TC, temp16);\ + }\ + while( obosc_tm_current != NULL ){\ + int length = TM_SHORT_SIZE;\ + if( GETshort_or_long_tm(obosc_tm_current) == SHORT_TM_CODE ){\ + length = TM_SHORT_SIZE;\ + }\ + else{\ + length = TM_LONG_SIZE;\ + }\ + for(int i = 0 ; i < length ; ++i){\ + /*gPC.putc(obosc_tm_current->TM_string[i]);*/\ + }\ + obosc_tm_current = obosc_tm_current->next_TM;\ + }\ + }\ + }\ + }\ + current_TC = current_TC->next_TC;\ + ++overCount;\ + }\ + else{\ + RESET_CDMS;\ + break;\ + }\ + }\ + }\ + if(obosc_tm_core != NULL){\ + Base_tm *obosc_tm_head = NULL;\ + get_call_sign(obosc_tm_head);\ + Base_tm *obosc_tm_current = obosc_tm_head;\ + get_ack_l1(obosc_tm_current->next_TM);\ + int overflowCountOBONLY = 0;\ + while( obosc_tm_current->next_TM != NULL ){\ + if( overflowCountOBONLY < TM_OVERFLOW_CONSTANT ){\ + obosc_tm_current = obosc_tm_current->next_TM;\ + ++overflowCountOBONLY;\ + }\ + else{\ + RESET_CDMS;\ + break;\ + }\ + }\ + obosc_tm_current->next_TM = obosc_tm;\ + /*Sending OBOSC TM to GS*/\ + /*snd_tm.head_pointer(obosc_tm_head);*/\ + /*transmit_adf;*/\ + /*DELETE THE TM AFTER USE*/\ + obosc_tm_current = obosc_tm_head;\ + int overCount = 0;\ + while( obosc_tm_current != NULL ){\ + if( (overCount < TM_OVERFLOW_CONSTANT) ){\ + Base_tm *temp = obosc_tm_current->next_TM;\ + delete obosc_tm_current;\ + obosc_tm_current = temp;\ + ++overCount;\ + }\ + else{\ + RESET_CDMS;\ + break;\ + }\ + }\ + }\ + if ( reset_flag == 1 ){\ + reset_all;\ + /*PENDING: Enable threads*/\ + /*gCDMS_HK_TIMER.start(5000);*/\ + gSESSION_TIMEOUT.detach();\ + }\ +} + +#define EXECUTE_TC {\ + gMASTER_STATE = TCL_STATE_EXECUTING;\ + if (DEBUG)\ + gPC.puts("iNSIDE EXECUTE_TC\r\n");\ + /*gPC.printf("%u\r\n", gTOTAL_VALID_TC);*/\ + for(uint8_t execute_psc = PSC_START_VALUE ; execute_psc < gTOTAL_VALID_TC ; ++execute_psc ){\ + if (DEBUG)\ + gPC.printf("executing normal %u\r\n", execute_psc);\ + /*gLEDG = !gLEDG;*/\ + /*gLEDR = !gLEDR;*/\ + Base_tc* current_TC = gHEAD_NODE_TCL;\ + int overflowCount = 0;\ + while(current_TC != NULL){\ + if( overflowCount < TCL_OVERFLOW_CONSTANT ){\ + if( (GETcrc_pass(current_TC) == 1) && (GETpacket_seq_count(current_TC) == execute_psc) ){\ + uint8_t current_exec_status = GETexec_status(current_TC);\ + if( (current_exec_status == TC_STATE_SUCCESSFULLY_EXECUTED) || (current_exec_status == TC_STATE_DISABLED) ){\ + /*gPC.printf("disabled or completed at %u\n", execute_psc);*/\ + if( execute_psc == (gTOTAL_VALID_TC-1) ){\ + /*LAST TC IS EXECUTED*/\ + gMASTER_STATE = TCL_STATE_COMPLETED;\ + }\ + break;\ + }\ + else if( (current_exec_status == TC_STATE_EXECUTION_FAILED) && (GETabort_on_nack(current_TC) == 1) ){\ + /*gPC.printf("abort on nack at %u psc\r\n", execute_psc);*/\ + gMASTER_STATE = TCL_STATE_ABORTED;\ + Base_tm *tm_ptr_head = NULL;\ + get_call_sign(tm_ptr_head);\ + Base_tm *tm_ptr = tm_ptr_head;\ + get_ack_l1(tm_ptr->next_TM);\ + tm_ptr = tm_ptr_head;\ + while( tm_ptr != NULL ){\ + int length = TM_SHORT_SIZE;\ + if( GETshort_or_long_tm(tm_ptr) == SHORT_TM_CODE ){\ + length = TM_SHORT_SIZE;\ + }\ + else{\ + length = TM_LONG_SIZE;\ + }\ + /*gPC.puts("Printing Call Sign, ACK_L1, TM list");*/\ + for(int i = 0 ; i < length ; ++i){\ + /*gPC.putc(tm_ptr->TM_string[i]);*/\ + }\ + tm_ptr = tm_ptr->next_TM;\ + }\ + /*Send only call sign, ACK_L1 to GS*/\ + /*snd_tm.head_pointer(tm_ptr_head);*/\ + /*transmit_adf;*/\ + /*DELETE THE TM AFTER USE*/\ + tm_ptr = tm_ptr_head;\ + int overflowCountExecute = 0;\ + while(tm_ptr != NULL){\ + if( overflowCountExecute < TM_OVERFLOW_CONSTANT ){\ + Base_tm *temp = tm_ptr->next_TM;\ + delete tm_ptr;\ + tm_ptr = temp;\ + ++overflowCountExecute;\ + }\ + else{\ + RESET_CDMS;\ + break;\ + }\ + }\ + break;\ + }\ + else if( (current_exec_status == TC_STATE_UNEXECUTED) || (current_exec_status == TC_STATE_MARKED_RETRY) ){\ + /*EXECUTION OF TC START*/\ + uint8_t temp81 = 0x00;\ + isit_sdcard(current_TC, temp81);\ + if( temp81 == 0x00 ){\ + if (DEBUG)\ + gPC.printf("non sd card at %u\r\n", execute_psc);\ + /*EXECUTION OF NON SD-CARD (BOTH OBOSC and CDMS functions)*/\ + Base_tm *tm_ptr_head = NULL;\ + get_call_sign(tm_ptr_head);\ + Base_tm *put_tm_here = NULL;\ + uint8_t temp82 = 0x00;\ + uint8_t tempPAhot = 0x00;\ + isit_obosc(current_TC, temp82);\ + if(temp82 == 0x01){\ + /*gPC.printf("obosc tc inside normal tc at %u\r\n", execute_psc);*/\ + /*EXECUTION OF OBOSC TC*/\ + /*SKIP EXECUTION OF OBOSC HERE*/\ + break;\ + }\ + else{\ + /*gPC.printf("cdms relay tmtc at %u\r\n", execute_psc);*/\ + put_tm_here = FCTN_CDMS_RLY_TMTC(current_TC);\ + }\ + /*DETECT ACK OR NACK*/\ + uint8_t temp83 = 0x00;\ + detect_ack(put_tm_here, temp83);\ + if( temp83 == 0x01){\ + uint16_t temp16 = TC_STATE_SUCCESSFULLY_EXECUTED;\ + PUTexec_status(current_TC, temp16);\ + }\ + else if( temp83 == 0x03){\ + /*gPC.puts("TC_STATE_EXECUTION_UNKNOWN");*/\ + uint16_t temp16 = TC_STATE_EXECUTION_UNKNOWN;\ + PUTexec_status(current_TC, temp16);\ + }\ + else if( temp83 == 0x04){\ + /*gPC.puts("TC_STATE_EXECUTION_UNKNOWN");*/\ + uint16_t temp16 = TC_STATE_EXECUTION_FAILED;\ + PUTexec_status(current_TC, temp16);\ + uint8_t temp84 = GETpacket_seq_count(current_TC);\ + put_tm_here->TM_string[2] = temp84;\ + uint16_t crc16 = crc16_gen(put_tm_here->TM_string, 11);\ + put_tm_here->TM_string[11] = (crc16 & 0xFF00)>>8;\ + put_tm_here->TM_string[12] = (crc16 & 0x00FF);\ + }\ + else{\ + /*gPC.puts("TC_STATE_EXECUTION_FAILED");*/\ + uint16_t temp16 = TC_STATE_EXECUTION_FAILED;\ + PUTexec_status(current_TC, temp16);\ + }\ + /*ABORT ON NACK AND TC LIST COMPLETED: UPDATE IN gMASTERSTATE*/\ + if( ((GETexec_status(current_TC) == TC_STATE_EXECUTION_FAILED) || (GETexec_status(current_TC) == TC_STATE_EXECUTION_UNKNOWN)) && (GETabort_on_nack(current_TC) == 1) ){\ + gMASTER_STATE = TCL_STATE_ABORTED;\ + }\ + else if( execute_psc == (gTOTAL_VALID_TC-1) ){\ + /*LAST TC IS EXECUTED*/\ + gMASTER_STATE = TCL_STATE_COMPLETED;\ + }\ + /*update last executed L1_ack*/\ + if( put_tm_here != NULL ){\ + Base_tm *ptr_tm = put_tm_here;\ + while(ptr_tm->next_TM != NULL)\ + ptr_tm = ptr_tm->next_TM;\ + if( GETshort_or_long_tm(ptr_tm) == SHORT_TM_CODE ){\ + for(int i = 0 ; i < TM_SHORT_SIZE ; ++i){\ + gLAST_TM[i] = ptr_tm->TM_string[i];\ + gLAST_TM_SHORT_OR_LONG = SHORT_TM_CODE;\ + }\ + }\ + else{\ + for( int i = 0 ; i < TM_LONG_SIZE ; ++i ){\ + gLAST_TM[i] = ptr_tm->TM_string[i];\ + gLAST_TM_SHORT_OR_LONG = LONG_TM_CODE;\ + }\ + }\ + }\ + P_COM_HK;\ + Base_tm *tm_ptr = tm_ptr_head;\ + get_ack_l1(tm_ptr->next_TM);\ + int overflowCountExecute = 0;\ + while( tm_ptr->next_TM != NULL ){\ + if( overflowCountExecute < TM_OVERFLOW_CONSTANT ){\ + tm_ptr = tm_ptr->next_TM;\ + ++overflowCountExecute;\ + }\ + else{\ + RESET_CDMS;\ + break;\ + }\ + }\ + tm_ptr->next_TM = put_tm_here;\ + tm_ptr = tm_ptr_head;\ + while( tm_ptr != NULL ){\ + int length = TM_SHORT_SIZE;\ + if( GETshort_or_long_tm(tm_ptr) == SHORT_TM_CODE ){\ + length = TM_SHORT_SIZE;\ + }\ + else{\ + length = TM_LONG_SIZE;\ + }\ + /*gPC.puts("Printing Call Sign, ACK_L1, TM list");*/\ + for(int i = 0 ; i < length ; ++i){\ + /*gPC.putc(tm_ptr->TM_string[i]);*/\ + }\ + tm_ptr = tm_ptr->next_TM;\ + }\ + /*SEND call sign, ACK_L1, NON OBSRS TM TO GS*/\ + snd_tm.head_pointer(tm_ptr_head);\ + gPC.puts("enter_adf\r\n");\ + transmit_adf;\ + gPC.puts("exit_adf\r\n");\ + /*DELETE THE TM AFTER USE*/\ + tm_ptr = tm_ptr_head;\ + overflowCountExecute = 0;\ + while(tm_ptr != NULL){\ + if( overflowCountExecute < TM_OVERFLOW_CONSTANT ){\ + Base_tm *temp = tm_ptr->next_TM;\ + delete tm_ptr;\ + tm_ptr = temp;\ + ++overflowCountExecute;\ + }\ + else{\ + RESET_CDMS;\ + break;\ + }\ + }\ + }\ + else{\ + if (DEBUG)\ + gPC.printf("sd card at %u\r\n", execute_psc);\ + /*EXECUTION OF SD-CARD DATA SENDING (OBSRS)*/\ + execute_OBSRS_TC(current_TC);\ + }\ + }\ + break;\ + }\ + current_TC = current_TC->next_TC;\ + ++overflowCount;\ + }\ + else{\ + RESET_CDMS;\ + break;\ + }\ + }\ + if( gFLAGS & COM_SESSION_TIMEOUT_FLAG ){\ + break;\ + }\ + else if( gMASTER_STATE == TCL_STATE_ABORTED ){\ + if (DEBUG)\ + gPC.puts("ABORTING DUE TO ABORT ON NACK\r\n");\ + /*EXITED DUE TO ABORT ON NACK:*/\ + COM_TX_CNTRL = 0;\ + RX1M.attach(&rx_read, Serial::RxIrq);\ + gFLAGS = gFLAGS & (~COM_MNG_TMTC_RUNNING_FLAG);\ + break;\ + }\ + else if( (gFLAGS & COM_PA_HOT_FLAG) || (gFLAGS & COM_PA_OC_FLAG) ){\ + /*PA HOT: WAIT FOR TIMEOUT*/\ + gCOM_PA_COOLING_TIMEOUT.attach(&after_cooling_pa, COM_PA_COOLING_TIME_LIMIT);\ + COM_TX_CNTRL = 0;\ + RX1M.attach(&rx_read, Serial::RxIrq);\ + gFLAGS = gFLAGS & (~COM_MNG_TMTC_RUNNING_FLAG);\ + break;\ + }\ + if (DEBUG)\ + gPC.printf("successflly executed %u tc\r\n", execute_psc);\ + }\ + if( (gMASTER_STATE == TCL_STATE_COMPLETED) || (gFLAGS & COM_SESSION_TIMEOUT_FLAG) ){\ + if (DEBUG)\ + gPC.printf("completed or session timed out: %x\r\n", gMASTER_STATE);\ + /*COMPLETED EXECUTION OF TC*/\ + gMASTER_STATE = TCL_STATE_COMPLETED;\ + COM_POWER_OFF_TX;\ + reset_all;\ + /*PENDING : ENABLE THREADS*/\ + /*gCDMS_HK_TIMER.start(5000);*/\ + gPAY_SPI.bulkRead_start();\ + gSESSION_TIMEOUT.detach();\ + gFLAGS = gFLAGS & (~COM_MNG_TMTC_RUNNING_FLAG);\ + gFLAGS = gFLAGS & (~COM_SESSION_FLAG);\ + }\ +} \ No newline at end of file
--- a/COM_POWER_OFF_TX.h Sun Jul 03 09:26:42 2016 +0000 +++ b/COM_POWER_OFF_TX.h Sun Jul 03 09:47:05 2016 +0000 @@ -1,136 +1,15 @@ -#define RESET_CDMS {\ - Base_tc *RESET_tc = new Short_tc;\ - RESET_tc->next_TC = NULL;\ - PUTshort_or_long(RESET_tc,SHORT_TC_CODE);\ - PUTcrc_pass(RESET_tc,0x1);\ - PUTexec_status(RESET_tc,0);\ - RESET_tc->TC_string[0] = 0x01;\ - RESET_tc->TC_string[1] = 0x81;\ - RESET_tc->TC_string[2] = 0x81;\ - RESET_tc->TC_string[3] = 0x38;\ - RESET_tc->TC_string[4] = 0;\ - RESET_tc->TC_string[5] = 0;\ - RESET_tc->TC_string[6] = 0;\ - RESET_tc->TC_string[7] = 0;\ - RESET_tc->TC_string[8] = 0;\ - uint16_t crc16 = crc16_gen(RESET_tc->TC_string, 9);\ - RESET_tc->TC_string[9] = (crc16 & 0xFF00)>>8;\ - RESET_tc->TC_string[10] = (crc16 & 0x00FF);\ - Base_tm *tm_ptr = NULL;\ - tm_ptr = FCTN_CDMS_RLY_TMTC(RESET_tc);\ - delete RESET_tc;\ - /*DELETE THE TM AFTER USE*/\ - Base_tm *del_tm = tm_ptr;\ - while( del_tm != NULL ){\ - Base_tm *temp = del_tm->next_TM;\ - delete del_tm;\ - del_tm = temp;\ - }\ -} - -#define power_on_bae {\ - Base_tc *power_on_BAE = new Short_tc;\ - power_on_BAE->next_TC = NULL;\ - PUTshort_or_long(power_on_BAE,SHORT_TC_CODE);\ - PUTcrc_pass(power_on_BAE,0x1);\ - PUTexec_status(power_on_BAE,0);\ - power_on_BAE->TC_string[0] = 0x01;\ - power_on_BAE->TC_string[1] = BAE_APID_SOURCE;\ - power_on_BAE->TC_string[2] = BAE_SERVICE;\ - power_on_BAE->TC_string[3] = BAE_POWER_ON_PID;\ - power_on_BAE->TC_string[4] = 0;\ - power_on_BAE->TC_string[5] = 0;\ - power_on_BAE->TC_string[6] = 0;\ - power_on_BAE->TC_string[7] = 0;\ - power_on_BAE->TC_string[8] = 0;\ - uint16_t crc16 = crc16_gen(power_on_BAE->TC_string, 9);\ - power_on_BAE->TC_string[9] = (crc16 & 0xFF00)>>8;\ - power_on_BAE->TC_string[10] = (crc16 & 0x00FF);\ - Base_tm *tm_ptr = NULL;\ - tm_ptr = FCTN_CDMS_RLY_TMTC(power_on_BAE);\ - delete power_on_BAE;\ - /*DELETE THE TM AFTER USE*/\ - Base_tm *del_tm = tm_ptr;\ - int overCount = 0;\ - while( del_tm != NULL ){\ - if( (overCount < TM_OVERFLOW_CONSTANT) ){\ - Base_tm *temp = del_tm->next_TM;\ - delete del_tm;\ - del_tm = temp;\ - ++overCount;\ - }\ - else{\ - RESET_CDMS;\ - break;\ - }\ - }\ -} - -#define resume_bcn {\ - Base_tc *beacon_tc = new Long_tc;\ - beacon_tc->next_TC = NULL;\ - PUTshort_or_long(beacon_tc,LONG_TC_CODE);\ - PUTcrc_pass(beacon_tc,0x1);\ - PUTexec_status(beacon_tc,0);\ - beacon_tc->TC_string[0] = 0x01;\ - beacon_tc->TC_string[1] = BCN_APID_SOURCE;\ - beacon_tc->TC_string[2] = BCN_SERVICE;\ - beacon_tc->TC_string[3] = 0xE2;\ - beacon_tc->TC_string[4] = 0x00;\ - beacon_tc->TC_string[5] = 0;\ - beacon_tc->TC_string[6] = 0;\ - beacon_tc->TC_string[7] = 0;\ - beacon_tc->TC_string[8] = 0;\ - uint16_t crc16 = crc16_gen(beacon_tc->TC_string, 9);\ - beacon_tc->TC_string[9] = (crc16 & 0xFF00)>>8;\ - beacon_tc->TC_string[10] = (crc16 & 0x00FF);\ - for(int i = 11; i < 135; i++){\ - beacon_tc->TC_string[i] = 0;\ - }\ - Base_tm *tm_ptr = NULL;\ - tm_ptr = FCTN_CDMS_RLY_TMTC(beacon_tc);\ - delete beacon_tc;\ - /*DELETE THE TM AFTER USE*/\ - Base_tm *del_tm = tm_ptr;\ - int overCount = 0;\ - while( del_tm != NULL ){\ - if( (overCount < TM_OVERFLOW_CONSTANT) ){\ - Base_tm *temp = del_tm->next_TM;\ - delete del_tm;\ - del_tm = temp;\ - ++overCount;\ - }\ - else{\ - RESET_CDMS;\ - break;\ - }\ - }\ -} - #define COM_POWER_OFF_TX {\ /*gPC.puts("Inside COM_POWER_OFF_TX\r\n");*/\ - COM_TX_CNTRL = 0;\ + /*PENDING: POWER OFF TRANSMITTER*/\ RX1M.attach(&rx_read, Serial::RxIrq);\ gFLAGS = gFLAGS & (~COM_MNG_TMTC_RUNNING_FLAG);\ - RF_SW_CNTRL_BCN = 1;\ - Thread::wait(25);\ - RF_SW_CNTRL_BCN = 0;\ - gFLAGS = gFLAGS | RF_SW_STATUS_FLAG;\ - if( gFLAGS & COM_AUTO_POWER_OFF_BAE_FLAG ){\ - power_on_bae;\ - gFLAGS = gFLAGS | BAE_SW_EN_FLAG;\ - gFLAGS & (~COM_AUTO_POWER_OFF_BAE_FLAG);\ - resume_bcn;\ - }\ - else{\ - if( gFLAGS & BAE_SW_EN_FLAG ){\ - resume_bcn;\ - }\ - }\ + /*PENDING: SWITCH RF RELAY TO BEACON*/\ + /*PENDING: RF_SW_STATUS = RF_BCN*/\ + /*PENDING: POWER ON BAE*/\ + /*PENDING: SET BAE SW_EN_STATUS*/\ + /*PENDING: RESUME BEACON*/\ gFLAGS = gFLAGS & (~COM_PA_HOT_FLAG);\ - gFLAGS = gFLAGS & (~COM_PA_OC_FLAG);\ gCOM_PA_COOLING_TIMEOUT.detach();\ gFLAGS = gFLAGS & (~COM_TX_FLAG);\ - gFLAGS = gFLAGS & (~COM_SESSION_TIMEOUT_FLAG);\ - /*gPC.puts("completed com_power_off tx\r\n");*/\ + /*gPC.puts("ompleted com_power_off tx\r\n");*/\ } \ No newline at end of file
--- a/COM_POWER_ON_TX.h Sun Jul 03 09:26:42 2016 +0000 +++ b/COM_POWER_ON_TX.h Sun Jul 03 09:47:05 2016 +0000 @@ -1,444 +1,107 @@ -#define STANDBY_PRCS(tm_ptr){\ - Base_tc *stdby_tc = new Long_tc;\ - stdby_tc->next_TC = NULL;\ - PUTshort_or_long(stdby_tc,LONG_TC_CODE);\ - PUTcrc_pass(stdby_tc,0x1);\ - PUTexec_status(stdby_tc,0);\ - stdby_tc->TC_string[0] = 0x01;\ - stdby_tc->TC_string[1] = 0x41;\ - stdby_tc->TC_string[2] = 0x81;\ - stdby_tc->TC_string[3] = 0x40;\ - stdby_tc->TC_string[4] = 0x01;\ - stdby_tc->TC_string[5] = 0x01;\ - stdby_tc->TC_string[6] = 0x01;\ - stdby_tc->TC_string[7] = 0;\ - stdby_tc->TC_string[8] = 0;\ - uint16_t crc16 = crc16_gen(stdby_tc->TC_string, 9);\ - stdby_tc->TC_string[9] = (crc16 & 0xFF00)>>8;\ - stdby_tc->TC_string[10] = (crc16 & 0x00FF);\ - for(int i = 11; i < 135; i++){\ - stdby_tc->TC_string[i] = 0;\ - }\ - tm_ptr = FCTN_CDMS_RLY_TMTC(stdby_tc);\ - delete stdby_tc;\ -} - -#define SET_BCN_STANDBY(tm_ptr){\ - Base_tc *beacon_tc = new Long_tc;\ - beacon_tc->next_TC = NULL;\ - PUTshort_or_long(beacon_tc,LONG_TC_CODE);\ - PUTcrc_pass(beacon_tc,0x1);\ - PUTexec_status(beacon_tc,0);\ - beacon_tc->TC_string[0] = 0x01;\ - beacon_tc->TC_string[1] = BCN_APID_SOURCE;\ - beacon_tc->TC_string[2] = BCN_SERVICE;\ - beacon_tc->TC_string[3] = 0xE2;\ - beacon_tc->TC_string[4] = 0x01;\ - beacon_tc->TC_string[5] = 0;\ - beacon_tc->TC_string[6] = 0;\ - beacon_tc->TC_string[7] = 0;\ - beacon_tc->TC_string[8] = 0;\ - uint16_t crc16 = crc16_gen(beacon_tc->TC_string, 9);\ - beacon_tc->TC_string[9] = (crc16 & 0xFF00)>>8;\ - beacon_tc->TC_string[10] = (crc16 & 0x00FF);\ - for(int i = 11; i < 135; i++){\ - beacon_tc->TC_string[i] = 0;\ - }\ - tm_ptr = FCTN_CDMS_RLY_TMTC(beacon_tc);\ - delete beacon_tc;\ -} - -#define reset_bae {\ - Base_tc *reset_BAE = new Short_tc;\ - reset_BAE->next_TC = NULL;\ - PUTshort_or_long(reset_BAE,SHORT_TC_CODE);\ - PUTcrc_pass(reset_BAE,0x1);\ - PUTexec_status(reset_BAE,0);\ - reset_BAE->TC_string[0] = 0x01;\ - reset_BAE->TC_string[1] = BAE_APID_SOURCE;\ - reset_BAE->TC_string[2] = BAE_SERVICE;\ - reset_BAE->TC_string[3] = BAE_RESET_PID;\ - reset_BAE->TC_string[4] = 0;\ - reset_BAE->TC_string[5] = 0;\ - reset_BAE->TC_string[6] = 0;\ - reset_BAE->TC_string[7] = 0;\ - reset_BAE->TC_string[8] = 0;\ - uint16_t crc16 = crc16_gen(reset_BAE->TC_string, 9);\ - reset_BAE->TC_string[9] = (crc16 & 0xFF00)>>8;\ - reset_BAE->TC_string[10] = (crc16 & 0x00FF);\ - Base_tm *tm_ptr = NULL;\ - tm_ptr = FCTN_CDMS_RLY_TMTC(reset_BAE);\ - delete reset_BAE;\ - /*DELETE THE TM AFTER USE*/\ - Base_tm *del_tm = tm_ptr;\ - int overCount = 0;\ - while( del_tm != NULL ){\ - if( (overCount < TM_OVERFLOW_CONSTANT) ){\ - Base_tm *temp = del_tm->next_TM;\ - delete del_tm;\ - del_tm = temp;\ - ++overCount;\ - }\ - else{\ - RESET_CDMS;\ - break;\ +#define COM_POWER_ON_TX {\ + /*gPC.puts("Inside COM_POWER_ON_TX\r\n");*/\ + if( !(gFLAGS & COM_TX_FLAG) ){\ + gFLAGS = gFLAGS | COM_TX_FLAG;\ + /*WARNING: INFINITE WHILE LOOP POSSIBLE: if standby ack received and bcn tx main status = 0*/\ + bool retryFlag = true;\ + while( retryFlag == true ){\ + uint8_t standbyAck = 0xFF;\ + /*PENDING: SET BEACON TO STANDBY*/\ + if( standbyAck == 0xFF ){\ + /*ACK RECCEIVED*/\ + /*PENDING: BEACON TX MAIN STATUS*/\ + if( true ){\ + retryFlag = false;\ + /*PENDING: SWITCH RELAY TO COM_TX*/\ + /*PENDING: RF_SW_STATUS = RF_COM_TX*/\ + }\ + else{\ + gCOM_MNG_TMTC_THREAD->wait(5000);\ + }\ + }\ + else{\ + /*PENDING: RESET BAE*/\ + uint8_t standbyAck2 = 0x00;\ + /*PENDING: SET BEACON TO STANDBY*/\ + if( standbyAck2 == 0xFF ){\ + /*PENDING: BEACON TX MAIN STAUTS*/\ + if( true ){\ + retryFlag = false;\ + /*PENDING: SWITCH RF RELAY TO COM TX*/\ + /*PENDING: RF_SW_STATUS = RF_COM_TX*/\ + }\ + }\ + else{\ + retryFlag = false;\ + /*PENDING: POWER OFF BEACON*/\ + /*PENDING: CLEAR BAE SW_EN*/\ + /*PENDING: SWITCH RF RELAY TO COM TX*/\ + /*PENDING: RF_SW_STATUS = RF_COM_TX*/\ + }\ + }\ }\ }\ -} - -#define power_off_bae {\ - Base_tc *power_off_BAE = new Short_tc;\ - power_off_BAE->next_TC = NULL;\ - PUTshort_or_long(power_off_BAE,SHORT_TC_CODE);\ - PUTcrc_pass(power_off_BAE,0x1);\ - PUTexec_status(power_off_BAE,0);\ - power_off_BAE->TC_string[0] = 0x01;\ - power_off_BAE->TC_string[1] = BAE_APID_SOURCE;\ - power_off_BAE->TC_string[2] = BAE_SERVICE;\ - power_off_BAE->TC_string[3] = BAE_POWER_OFF_PID;\ - power_off_BAE->TC_string[4] = 0;\ - power_off_BAE->TC_string[5] = 0;\ - power_off_BAE->TC_string[6] = 0;\ - power_off_BAE->TC_string[7] = 0;\ - power_off_BAE->TC_string[8] = 0;\ - uint16_t crc16 = crc16_gen(power_off_BAE->TC_string, 9);\ - power_off_BAE->TC_string[9] = (crc16 & 0xFF00)>>8;\ - power_off_BAE->TC_string[10] = (crc16 & 0x00FF);\ - Base_tm *tm_ptr = NULL;\ - tm_ptr = FCTN_CDMS_RLY_TMTC(power_off_BAE);\ - delete power_off_BAE;\ - /*DELETE THE TM AFTER USE*/\ - Base_tm *del_tm = tm_ptr;\ - int overCount = 0;\ - while( del_tm != NULL ){\ - if( (overCount < TM_OVERFLOW_CONSTANT) ){\ - Base_tm *temp = del_tm->next_TM;\ - delete del_tm;\ - del_tm = temp;\ - ++overCount;\ - }\ - else{\ - RESET_CDMS;\ - break;\ - }\ - }\ -} - -#define P_CDMS_HK_MAIN {\ - Base_tc *hk_main_ptr = new Short_tc;\ - hk_main_ptr->next_TC = NULL;\ - PUTshort_or_long(hk_main_ptr,SHORT_TC_CODE);\ - PUTcrc_pass(hk_main_ptr,0x1);\ - PUTexec_status(hk_main_ptr,0);\ - hk_main_ptr->TC_string[0] = 0x01;\ - hk_main_ptr->TC_string[1] = 0x81;\ - hk_main_ptr->TC_string[2] = 0x81;\ - hk_main_ptr->TC_string[3] = 0x04;\ - hk_main_ptr->TC_string[4] = 0;\ - hk_main_ptr->TC_string[5] = 0;\ - hk_main_ptr->TC_string[6] = 0;\ - hk_main_ptr->TC_string[7] = 0;\ - hk_main_ptr->TC_string[8] = 0;\ - uint16_t crc16 = crc16_gen(hk_main_ptr->TC_string, 9);\ - hk_main_ptr->TC_string[9] = (crc16 & 0xFF00)>>8;\ - hk_main_ptr->TC_string[10] = (crc16 & 0x00FF);\ - Base_tm *tm_ptr = NULL;\ - tm_ptr = FCTN_CDMS_RLY_TMTC(hk_main_ptr);\ - delete hk_main_ptr;\ - /*DELETE THE TM AFTER USE*/\ - Base_tm *del_tm = tm_ptr;\ - int overCount = 0;\ - while( del_tm != NULL ){\ - if( (overCount < TM_OVERFLOW_CONSTANT) ){\ - Base_tm *temp = del_tm->next_TM;\ - delete del_tm;\ - del_tm = temp;\ - ++overCount;\ - }\ - else{\ - RESET_CDMS;\ + /*PENDING: POWER ON COM_TX*/\ + uint8_t adfConfigPass = 0xFF;\ + for( int i = 0 ; i < COM_TX_CONFIG_LIMIT ; ++i ){\ + /*PENDING: CONFIGURE ADF*/\ + if( adfConfigPass == 0xFF ){\ break;\ }\ }\ -} - -#define P_BCN_TX_MAIN(tm_ptr) {\ - Base_tc *bcn_tx_main_ptr = new Long_tc;\ - bcn_tx_main_ptr->next_TC = NULL;\ - PUTshort_or_long(bcn_tx_main_ptr,LONG_TC_CODE);\ - PUTcrc_pass(bcn_tx_main_ptr,0x1);\ - PUTexec_status(bcn_tx_main_ptr,0);\ - bcn_tx_main_ptr->TC_string[0] = 0x01;\ - bcn_tx_main_ptr->TC_string[1] = 0x41;\ - bcn_tx_main_ptr->TC_string[2] = 0x81;\ - bcn_tx_main_ptr->TC_string[3] = 0x07;\ - bcn_tx_main_ptr->TC_string[4] = 0;\ - bcn_tx_main_ptr->TC_string[5] = 0;\ - bcn_tx_main_ptr->TC_string[6] = 0;\ - bcn_tx_main_ptr->TC_string[7] = 0;\ - bcn_tx_main_ptr->TC_string[8] = 0;\ - uint16_t crc16 = crc16_gen(bcn_tx_main_ptr->TC_string, 9);\ - bcn_tx_main_ptr->TC_string[9] = (crc16 & 0xFF00)>>8;\ - bcn_tx_main_ptr->TC_string[10] = (crc16 & 0x00FF);\ - for(int i = 11; i < 135; i++){\ - bcn_tx_main_ptr->TC_string[i] = 0;\ + if( adfConfigPass == 0xFF ){\ + /*adf successfully configured*/\ + /*CALL SIGN*/\ + Base_tm *power_on_tm = NULL;\ + Base_tm *power_on_tm_head = NULL;\ + get_call_sign( power_on_tm_head );\ + power_on_tm = power_on_tm_head;\ + /*ACK L1*/\ + get_ack_l1(power_on_tm->next_TM);\ + int overFlowCountADF = 0;\ + while( power_on_tm->next_TM != NULL ){\ + if( overFlowCountADF < TM_OVERFLOW_CONSTANT ){\ + power_on_tm = power_on_tm->next_TM;\ + ++overFlowCountADF;\ + }\ + else{\ + /*PENDING: RESET CDMS*/\ + break;\ + }\ + }\ + get_tc_list(power_on_tm->next_TM, 0x00);\ + /*PENDING: TRANSMIT ABOVE TM*/\ + /*Call Sign, ACK_L1, TC_LIST*/\ + /*snd_tm.head_pointer(power_on_tm_head);*/\ + /*transmit_adf;*/\ + /*deleting the telemetry*/\ + power_on_tm = power_on_tm_head;\ + overFlowCountADF = 0;\ + while( power_on_tm != NULL ){\ + if( overFlowCountADF < TM_OVERFLOW_CONSTANT ){\ + Base_tm *temp = power_on_tm->next_TM;\ + delete power_on_tm;\ + power_on_tm = temp;\ + ++overFlowCountADF;\ + }\ + else{\ + /*PENDING: RESET CDMS*/\ + break;\ + }\ + }\ }\ - tm_ptr = FCTN_CDMS_RLY_TMTC(bcn_tx_main_ptr);\ - delete bcn_tx_main_ptr;\ -} - -void COM_POWER_ON_TX() { - if (DEBUG) - gPC.puts("Inside COM_POWER_ON_TX\r\n"); - if( !(gFLAGS & COM_TX_FLAG) ){ - gFLAGS = gFLAGS | COM_TX_FLAG; - if( gFLAGS & BAE_SW_EN_FLAG ){ - /*WARNING: INFINITE WHILE LOOP POSSIBLE: if standby ack received and bcn tx main status = 0*/ - bool retryFlag = true; - while( retryFlag == true ){ - Base_tm *tm_ptr = NULL; - SET_BCN_STANDBY(tm_ptr); - uint8_t bcn_main_status = (tm_ptr->TM_string[2] & 0xEF); - if(( bcn_main_status == 0xC0 )||( bcn_main_status ==0xA0 )){ - /*ACK RECCEIVED*/ - if( bcn_main_status == 0xA0 ){ - retryFlag = false; - RF_SW_CNTRL_TX = 1; - Thread::wait(25); - RF_SW_CNTRL_TX = 0; - gFLAGS = gFLAGS & (~RF_SW_STATUS_FLAG);/*RF_SW_STATUS_FLAG set to RF_COM_TX*/ - } - else{ - Thread::wait(5000); - } - } - else{ - reset_bae; - Base_tm *tm_ptr2 = NULL; - SET_BCN_STANDBY(tm_ptr2); - uint8_t standbyAck2 = 0; - uint8_t bcn_main_status2 = (tm_ptr2->TM_string[2] & 0xEF); - if( ( bcn_main_status2 == 0xC0 )||( bcn_main_status2 == 0xA0 ) ){ - if( bcn_main_status2 == 0xA0 ){ - retryFlag = false; - RF_SW_CNTRL_TX = 1; - Thread::wait(25); - RF_SW_CNTRL_TX = 0; - gFLAGS = gFLAGS & (~RF_SW_STATUS_FLAG); - } - else{ - Thread::wait(5000); - } - } - else{ - retryFlag = false; - power_off_bae; - gFLAGS = gFLAGS | COM_AUTO_POWER_OFF_BAE_FLAG; - gFLAGS = gFLAGS & (~BAE_SW_EN_FLAG); - RF_SW_CNTRL_TX = 1; - Thread::wait(25); - RF_SW_CNTRL_TX = 0; - gFLAGS = gFLAGS & (~RF_SW_STATUS_FLAG);/*RF_SW_STATUS_FLAG set to RF_COM_TX*/ - } - /*DELETE THE TM AFTER USE*/ - Base_tm *del_tm = tm_ptr2; - int overCount = 0; - while( del_tm != NULL ){ - if( (overCount < TM_OVERFLOW_CONSTANT) ){ - Base_tm *temp = del_tm->next_TM; - delete del_tm; - del_tm = temp; - ++overCount; - } - else{ - RESET_CDMS; - break; - } - } - } - /*DELETE THE TM AFTER USE*/ - Base_tm *del_tm = tm_ptr; - int overCount = 0; - while( del_tm != NULL ){ - if( (overCount < TM_OVERFLOW_CONSTANT) ){ - Base_tm *temp = del_tm->next_TM; - delete del_tm; - del_tm = temp; - ++overCount; - } - else{ - RESET_CDMS; - break; - } - } - } - } - else{ - RF_SW_CNTRL_TX = 1; - Thread::wait(25); - RF_SW_CNTRL_TX = 0; - gFLAGS = gFLAGS & (~RF_SW_STATUS_FLAG);/*RF_SW_STATUS_FLAG set to RF_COM_TX*/ - } - } - COM_TX_CNTRL = 1; - uint8_t adfConfigPass = 0xFF; - for( int i = 0 ; i < COM_TX_CONFIG_LIMIT ; ++i ){ - /*PENDING: CONFIGURE ADF and set adfConfigPass*/ - if( adfConfigPass == 0xFF ){ - break; - } - } - if( adfConfigPass == 0xFF ){ - /*adf successfully configured*/ - gFLAGS = gFLAGS | COM_TX_STATUS_FLAG; - /*CALL SIGN*/ - Base_tm *power_on_tm = NULL; - Base_tm *power_on_tm_head = NULL; - get_call_sign( power_on_tm_head ); - power_on_tm = power_on_tm_head; - /*ACK L1*/ - get_ack_l1(power_on_tm->next_TM); - int overFlowCountADF = 0; - while( power_on_tm->next_TM != NULL ){ - if( overFlowCountADF < TM_OVERFLOW_CONSTANT ){ - power_on_tm = power_on_tm->next_TM; - ++overFlowCountADF; - } - else{ - RESET_CDMS; - break; - } - } - get_tc_list(power_on_tm->next_TM, 0x00); - /*Call Sign, ACK_L1, TC_LIST*/ - /*snd_tm.head_pointer(power_on_tm_head);*/ - /*transmit_adf;*/ - uint8_t transmissionPass = 0xFF; - /*PENDING: get acknowledgement of transmission*/ - /*deleting the telemetry*/ - power_on_tm = power_on_tm_head; - overFlowCountADF = 0; - while( power_on_tm != NULL ){ - if( overFlowCountADF < TM_OVERFLOW_CONSTANT ){ - Base_tm *temp = power_on_tm->next_TM; - delete power_on_tm; - power_on_tm = temp; - ++overFlowCountADF; - } - else{ - RESET_CDMS; - break; - } - } - if( transmissionPass == 0 ){ - /*NOT Transmitted succesfully*/ - COM_POWER_OFF_TX; - P_CDMS_HK_MAIN; - Base_tm *ptr_tm = NULL; - STANDBY_PRCS(ptr_tm); - uint8_t standbyACK = 0x00; - uint8_t bcn_main_status = (ptr_tm->TM_string[2] & 0xEF); - if(( bcn_main_status == 0xC0 )||( bcn_main_status ==0xA0 )){ - standbyACK = 1; - } - if(standbyACK == 1){ - uint8_t ackReceived = 0x00; - Base_tm *tm_ptr = NULL; - P_BCN_TX_MAIN(tm_ptr); - uint8_t ackcode = tm_ptr->TM_string[2] & 0xEF; - if( (ackcode == 0xA0) || (ackcode == 0xC0)) - ackReceived = 0xFF; - /*DELETE THE TM AFTER USE*/ - Base_tm *del_tm = tm_ptr; - int overCount = 0; - while( del_tm != NULL ){ - if( (overCount < TM_OVERFLOW_CONSTANT) ){ - Base_tm *temp = del_tm->next_TM; - delete del_tm; - del_tm = temp; - ++overCount; - } - else{ - RESET_CDMS; - break; - } - } - if( ackReceived == 0xFF ){ - Thread::wait(5000); - } - } - /*DELETE THE TM AFTER USE*/ - Base_tm *del_tm = ptr_tm; - int overCount = 0; - while( del_tm != NULL ){ - if( (overCount < TM_OVERFLOW_CONSTANT) ){ - Base_tm *temp = del_tm->next_TM; - delete del_tm; - del_tm = temp; - ++overCount; - } - else{ - RESET_CDMS; - break; - } - } - RESET_CDMS; - } - } - else{ - /*ADF not configured*/ - gFLAGS = gFLAGS & (~COM_TX_STATUS_FLAG); - COM_POWER_OFF_TX; - P_CDMS_HK_MAIN; - Base_tm *ptr_tm = NULL; - STANDBY_PRCS(ptr_tm); - uint8_t standbyACK = 0x00; - uint8_t bcn_main_status = (ptr_tm->TM_string[2] & 0xEF); - if(( bcn_main_status == 0xC0 )||( bcn_main_status ==0xA0 )){ - standbyACK = 1; - } - if(standbyACK == 1){ - uint8_t ackReceived = 0x00; - Base_tm *tm_ptr = NULL; - P_BCN_TX_MAIN(tm_ptr); - uint8_t ackcode = tm_ptr->TM_string[2] & 0xEF; - if( (ackcode == 0xA0) || (ackcode == 0xC0)) - ackReceived = 0xFF; - /*DELETE THE TM AFTER USE*/ - Base_tm *del_tm = tm_ptr; - int overCount = 0; - while( del_tm != NULL ){ - if( (overCount < TM_OVERFLOW_CONSTANT) ){ - Base_tm *temp = del_tm->next_TM; - delete del_tm; - del_tm = temp; - ++overCount; - } - else{ - RESET_CDMS; - break; - } - } - if( ackReceived == 0xFF ){ - Thread::wait(5000); - } - } - /*DELETE THE TM AFTER USE*/ - Base_tm *del_tm = ptr_tm; - int overCount = 0; - while( del_tm != NULL ){ - if( (overCount < TM_OVERFLOW_CONSTANT) ){ - Base_tm *temp = del_tm->next_TM; - delete del_tm; - del_tm = temp; - ++overCount; - } - else{ - RESET_CDMS; - break; - } - } - RESET_CDMS; - } - /*gPC.puts("COMPLETED COM_POWER_ON_TX\r\n");*/ + else{\ + /*PENDING: COM_POWER OFF TX*/\ + /*PENDING: CDMS HK MAIN*/\ + uint8_t ackReceived = 0x00;\ + /*PENDING: BCN TX MAIN*/\ + if( ackReceived == 0xFF ){\ + gCOM_MNG_TMTC_THREAD->wait(5000);\ + /*PENDING: RESET CDMS*/\ + }\ + else{\ + /*PENDING: RESET CDMS*/\ + }\ + }\ + /*gPC.puts("COMPLETED COM_POWER_ON_TX\r\n");*/\ } \ No newline at end of file
--- a/COM_RCV_TC.h Sun Jul 03 09:26:42 2016 +0000 +++ b/COM_RCV_TC.h Sun Jul 03 09:47:05 2016 +0000 @@ -261,4 +261,5 @@ gRX_COUNT = 0; /*gPC.puts("Completed conversion of raw_data\r\n")*/; + // PENDING: SORT THE LINKED LIST ACCORDING TO PSC VALUE } \ No newline at end of file
--- a/Compression.h Sun Jul 03 09:26:42 2016 +0000 +++ b/Compression.h Sun Jul 03 09:47:05 2016 +0000 @@ -74,7 +74,8 @@ sci_time = 0; gPC.puts("enter srp"); - + TIME_LATEST_SPI_SPEED = FCTN_CDMS_RD_RTC() >> 7; + PL_RCV_SC_DATA_COUNTER++; //Call FCTN_SD_MNGR for latest fsc FCTN_SD_MNGR();
--- a/DefinitionsAndGlobals.h Sun Jul 03 09:26:42 2016 +0000 +++ b/DefinitionsAndGlobals.h Sun Jul 03 09:47:05 2016 +0000 @@ -3,152 +3,150 @@ #define bypass_adf 1 // COM_RX - #define RX_TIMEOUT_LIMIT 0.5 - //#define COM_RX_UART_TX PTE20 // For bypassing RX1M (SET BAUD RATE 1200) #define COM_RX_UART_TX USBTX - //#define COM_RX_UART_RX PTE21 // For bypassing RX1M (SET BAUD RATE 1200) #define COM_RX_UART_RX USBRX - - #define COM_RX_UART_TX USBTX - #define COM_RX_UART_RX USBRX - +#define RX_TIMEOUT_LIMIT 0.5 +//#define COM_RX_UART_TX PTE20 // For bypassing RX1M (SET BAUD RATE 1200) #define COM_RX_UART_TX USBTX +//#define COM_RX_UART_RX PTE21 // For bypassing RX1M (SET BAUD RATE 1200) #define COM_RX_UART_RX USBRX + +#define COM_RX_UART_TX USBTX +#define COM_RX_UART_RX USBRX + // COMMON SPI - #define SPI_MOSI PTE1 - #define SPI_MISO PTE3 - #define SPI_CLK PTE2 - #define SPI_CS_ADF PTA15 - #define SPI_CS_SDC PIN20 - #define SPI_CS_RTC PIN26 - +#define SPI_MOSI PTE1 +#define SPI_MISO PTE3 +#define SPI_CLK PTE2 +#define SPI_CS_ADF PTA15 +#define SPI_CS_SDC PIN20 +#define SPI_CS_RTC PIN26 + // COM_TX - #define COM_TX_CONFIG_LIMIT 3 - #define COM_TX_TICKER_LIMIT 32 +#define COM_TX_CONFIG_LIMIT 3 +#define COM_TX_TICKER_LIMIT 32 // ADF INTERRUPT - #define ADF_IRQ PTA14 - +#define ADF_IRQ PTA14 + //I2C - Payload to CDMS (need to change while using CDMS hardware); - I2C master(PIN32,PIN31); - DigitalIn PL_I2C_Intr(PTC13); - DigitalOut PL_I2C_GPIO(PTC1); - +I2C master(PIN32,PIN31); +DigitalIn PL_I2C_Intr(PTC13); +DigitalOut PL_I2C_GPIO(PTC1); + //I2C - CDMS to BAE - DigitalIn BAE_I2C_GPIO(PIN39); - DigitalOut CDMS_I2C_GPIO(PIN67); +DigitalIn BAE_I2C_GPIO(PIN39); +DigitalOut CDMS_I2C_GPIO(PIN67); // TC LIST - #define TCL_STATE_INCOMPLETE 0x00 - #define TCL_STATE_ABORTED 0x01 - #define TCL_STATE_EXECUTING 0x02 - #define TCL_STATE_COMPLETED 0x03 +#define TCL_STATE_INCOMPLETE 0x00 +#define TCL_STATE_ABORTED 0x03 +#define TCL_STATE_EXECUTING 0x04 +#define TCL_STATE_COMPLETED 0x05 +#define TCL_STATE_EXCEEDED_LIMIT 0x06 // LIST OF FLAGS - #define UART_INT_FLAG 0x0001 - #define NEW_TC_RECEIVED 0x0002 - #define COM_SESSION_FLAG 0x0004 - #define COM_RX_FLAG 0x0008 - #define COM_MNG_TMTC_RUNNING_FLAG 0x0010 - #define COM_SESSION_VALIDITY 0x0020 - #define ALL_CRC_PASS_FLAG 0x0040 - #define COM_PA_HOT_FLAG 0x0080 - #define COM_PA_OC_FLAG 0x8000 - #define COM_TX_FLAG 0x0100 - #define COM_SESSION_TIMEOUT_FLAG 0x0200 - #define COM_AUTO_POWER_OFF_BAE_FLAG 0x0400 - #define BAE_SW_EN_FLAG 0x0800 - #define RF_SW_STATUS_FLAG 0x1000 - #define COM_INIT_STATUS_FLAG 0x2000 - #define COM_TX_STATUS_FLAG 0x4000 +#define UART_INT_FLAG 0x0001 +#define NEW_TC_RECEIVED 0x0002 +#define COM_SESSION_FLAG 0x0004 +#define COM_RX_FLAG 0x0008 +#define COM_MNG_TMTC_RUNNING_FLAG 0x0010 +#define COM_SESSION_VALIDITY 0x0020 +#define ALL_CRC_PASS_FLAG 0x0040 +#define COM_PA_HOT_FLAG 0x0080 +#define COM_TX_FLAG 0x0100 +#define COM_SESSION_TIMEOUT_FLAG 0x0200 +#define COM_AUTO_POWER_OFF_BAE_FLAG 0x0400 +#define BAE_SW_EN_FLAG 0x0800 +#define RF_SW_STATUS_FLAG 0x1000 +#define COM_INIT_STATUS_FLAG 0x2000 +#define COM_TX_STATUS_FLAG 0x4000 //RF relay STATUS - #define RF_COM_TX 0 - #define RF_BCN 1 +#define RF_COM_TX 0 +#define RF_BCN 1 // COM_MNG_TMTC THREAD - #define SESSION_TIME_LIMIT 1500 - #define COM_RX_DISABLE_TIMEOUT 10 - #define COM_MNG_TMTC_SIGNAL_UART_INT 0x01 - #define COM_MNG_TMTC_SIGNAL_ADF_NSD 0x02 - #define COM_MNG_TMTC_SIGNAL_ADF_SD 0x03 - #define SCIENCE_SIGNAL 0x04 +#define SESSION_TIME_LIMIT 1500 +#define COM_MNG_TMTC_SIGNAL_UART_INT 0x01 +#define COM_MNG_TMTC_SIGNAL_ADF_NSD 0x02 +#define COM_MNG_TMTC_SIGNAL_ADF_SD 0x03 +#define SCIENCE_SIGNAL 0x04 // COM_MNG_TMTC - #define COM_PA_COOLING_TIME_LIMIT 20 - #define COM_MAX_TC_LIMIT 256 - #define TM_ACK_CODE_INDEX 2 - #define CRC_FAIL_NACK_CODE 0x01 - - // call sign - #define PSC_CALLSIGN 0x00 - #define APID_CALLSIGN 0x00 - - // max value of telecommands in a tcl - #define TCL_OVERFLOW_CONSTANT 256 - #define TM_OVERFLOW_CONSTANT 256 - #define BYTE_OVERFLOW_CONSTANT 35000 +#define COM_PA_COOLING_TIME_LIMIT 20 +#define COM_MAX_TC_LIMIT 200 +#define TM_ACK_CODE_INDEX 2 +#define CRC_FAIL_NACK_CODE 0x01 + +// call sign +#define PSC_CALLSIGN 0x00 +#define APID_CALLSIGN 0x00 + +// max value of telecommands in a tcl +#define TCL_OVERFLOW_CONSTANT 256 +#define TM_OVERFLOW_CONSTANT 256 + +// starting value of packet sequence count at each pass +#define PSC_START_VALUE 1 - // starting value of packet sequence count at each pass - #define PSC_START_VALUE 1 - - // APID list - #define APID_COM 0 - #define APID_BAE 1 - #define APID_CDMS 2 - #define APID_SPEED 3 - - //SERVICE - #define SERVICE_OBOSC 0xB - #define SERVICE_OBSRS 0xF - - // HIGH PRIORITY TC - priority list - // not correct values here - #define HPTC1 5 - #define HPTC2 6 - // Add more entries above - - // SIZE of tc in bytes - #define TC_SHORT_SIZE 11 - #define TC_LONG_SIZE 135 - - // TMID list - #define TMID_ACK_L1 0xA - #define TMID_ACK_L234 0xB - #define TMID_TCL 0x7 - #define TMID_CALL_SIGN 0xE +// APID list +#define APID_COM 0 +#define APID_BAE 1 +#define APID_CDMS 2 +#define APID_SPEED 3 + +//SERVICE +#define SERVICE_OBOSC 0xB +#define SERVICE_OBSRS 0xF + +// HIGH PRIORITY TC - priority list +// not correct values here +#define HPTC1 5 +#define HPTC2 6 +// Add more entries above + +// SIZE of tc in bytes +#define TC_SHORT_SIZE 11 +#define TC_LONG_SIZE 135 + +// TMID list +#define TMID_ACK_L1 0xA +#define TMID_ACK_L234 0xB +#define TMID_TCL 0x7 +#define TMID_CALL_SIGN 0xE // OBOSC SERVICE SUBTYPE - #define OBOSC_TCL_MAX_SHORT_SIZE 11 - #define OBOSC_LONG_TC_FIRST_HALF_SIZE 67 - #define OBOSC_LONG_TC_SECOND_HALF_SIZE 68 - #define OBOSC_TCL_TAG_LONG_FIRST_HALF 0x10 - #define OBOSC_TCL_TAG_LONG_SECOND_HALF 0x11 +#define OBOSC_TCL_MAX_SHORT_SIZE 11 +#define OBOSC_LONG_TC_FIRST_HALF_SIZE 67 +#define OBOSC_LONG_TC_SECOND_HALF_SIZE 68 +#define OBOSC_TCL_TAG_LONG_FIRST_HALF 0x10 +#define OBOSC_TCL_TAG_LONG_SECOND_HALF 0x11 - #define OBOSC_SUB_DISABLE 0x01 - #define OBOSC_SUB_RETRY 0x05 - #define OBOSC_SUB_REP_TCLD 0x06 - #define OBOSC_SUB_REP_LE 0x0F - #define OBOSC_SUB_RESET 0x07 - +#define OBOSC_SUB_DISABLE 0x01 +#define OBOSC_SUB_RETRY 0x05 +#define OBOSC_SUB_REP_TCLD 0x06 +#define OBOSC_SUB_REP_LE 0x0F +#define OBOSC_SUB_RESET 0x07 + // PAYLOAD or SCIENCE - #define PAYLOAD_BUFFER_LENGTH 6723 - #define PAY_SPI_MOSI PTE18 - #define PAY_SPI_MISO PTE19 - #define PAY_SPI_CLK PTE17 - #define PAY_SPI_CS PTE16 +#define PAYLOAD_BUFFER_LENGTH 6723 +#define PAY_SPI_MOSI PTE18 +#define PAY_SPI_MISO PTE19 +#define PAY_SPI_CLK PTE17 +#define PAY_SPI_CS PTE16 //BEACON - #define BCN_APID_SOURCE 0x41 - #define BCN_SERVICE 0x81 - +#define BCN_APID_SOURCE 0x41 +#define BCN_SERVICE 0x81 + //BAE - #define BAE_APID_SOURCE 0x81 - #define BAE_SERVICE 0x81 - #define BAE_POWER_ON_PID 0x13 - #define BAE_POWER_OFF_PID 0x23 - #define BAE_RESET_PID 0x33 +#define BAE_APID_SOURCE 0x81 +#define BAE_SERVICE 0x81 +#define BAE_POWER_ON_PID 0x13 +#define BAE_POWER_OFF_PID 0x23 +#define BAE_RESET_PID 0x33 //RF RELAY - #define RF_RELAY_CNTRL_TX PTA7 - #define RF_RELAY_CNTRL_BCN PTA12 +#define RF_RELAY_CNTRL_TX PTA7 +#define RF_RELAY_CNTRL_BCN PTA12 - + // ****************GLOBAL VARIABLES****************** // DEBUG Serial gPC( USBTX, USBRX ); @@ -161,7 +159,6 @@ COM_RX_DATA_NODE *gRX_CURRENT_DATA_NODE = NULL; // uint8_t *gRX_CURRENT_PTR = NULL; uint32_t gRX_COUNT = 0; -uint16_t gTOTAL_RAW_BYTES = 0; uint16_t gTOTAL_INCORRECT_SIZE_TC = 0x00; uint16_t gTOTAL_CRC_FAIL_TC = 0x00; uint16_t gTOTAL_REPEATED_TC = 0x00; @@ -194,7 +191,6 @@ Thread* gCOM_MNG_TMTC_THREAD = NULL; Timeout gRX_TIMEOUT; Timeout gSESSION_TIMEOUT; -Timeout gCOM_RX_DISABLE; // COM_MNG_TMTC @@ -226,7 +222,7 @@ uint8_t CDMS_HEALTH_DATA[128]; uint8_t CDMS_RAM[59]; uint16_t GPIO_STATUS; -uint8_t CDMS_HK_MAIN_STATUS; +uint8_t CDMS_HK_MAIN_STATUS; uint8_t COMRX_STATUS; uint8_t RTC_FAULTCOUNT; uint16_t SD_FAULTCOUNT; @@ -303,4 +299,23 @@ uint8_t CDMS_STANDBY_PL; uint8_t CDMS_INIT_STATUS; uint8_t CDMS_HK_STATUS; -uint8_t CDMS_RTC_BL; \ No newline at end of file +uint8_t CDMS_RTC_BL; + +//FLASH parameters +uint8_t EPS_V_A_EN_STATUS; +uint8_t BAE_SW_STATUS; +uint8_t CDMS_SD_SW_STATUS; +uint8_t PL_BEE_SW_STATUS =0 ; +uint8_t PL_EPS_LATCH_SW_EN; +uint8_t RTC_INIT_STATUS; +uint8_t CDMS_RTC_DISABLE; +uint8_t CDMS_RESET_COUNTER; +uint8_t TIME_LATEST_CDSMS_RESET; +uint8_t COM_TC_BYTES_LIMIT; +uint8_t COM_RX_CURRENT_MAX; +uint8_t COM_RX_DISABLE_TIMEOUT; +uint8_t COM_PA_TMP_HIGH; +uint8_t COM_PA_RECOVERY_TIMEOUT; +uint8_t COM_SESSION_TIMEOUT; +uint8_t COM_RSSI_MIN; +uint8_t SD_LIB_BLK_CURRENT_NMBR; \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/DefinitionsAndGlobals.h.orig Sun Jul 03 09:47:05 2016 +0000 @@ -0,0 +1,306 @@ +// **************DEFINITIONS********************* + +#define bypass_adf 1 + +// COM_RX + #define RX_TIMEOUT_LIMIT 0.5 + //#define COM_RX_UART_TX PTE20 // For bypassing RX1M (SET BAUD RATE 1200) #define COM_RX_UART_TX USBTX + //#define COM_RX_UART_RX PTE21 // For bypassing RX1M (SET BAUD RATE 1200) #define COM_RX_UART_RX USBRX + + #define COM_RX_UART_TX USBTX + #define COM_RX_UART_RX USBRX + +// COMMON SPI + #define SPI_MOSI PTE1 + #define SPI_MISO PTE3 + #define SPI_CLK PTE2 + #define SPI_CS_ADF PTA15 + #define SPI_CS_SDC PIN20 + #define SPI_CS_RTC PIN26 + +// COM_TX + #define COM_TX_CONFIG_LIMIT 3 + #define COM_TX_TICKER_LIMIT 32 + +// ADF INTERRUPT + #define ADF_IRQ PTA14 + +//I2C - Payload to CDMS (need to change while using CDMS hardware); + I2C master(PIN32,PIN31); + DigitalIn PL_I2C_Intr(PTC13); + DigitalOut PL_I2C_GPIO(PTC1); + +//I2C - CDMS to BAE + DigitalIn BAE_I2C_GPIO(PIN39); + DigitalOut CDMS_I2C_GPIO(PIN67); + +// TC LIST + #define TCL_STATE_INCOMPLETE 0x00 + #define TCL_STATE_ABORTED 0x01 + #define TCL_STATE_EXECUTING 0x02 + #define TCL_STATE_COMPLETED 0x03 + +// LIST OF FLAGS + #define UART_INT_FLAG 0x0001 + #define NEW_TC_RECEIVED 0x0002 + #define COM_SESSION_FLAG 0x0004 + #define COM_RX_FLAG 0x0008 + #define COM_MNG_TMTC_RUNNING_FLAG 0x0010 + #define COM_SESSION_VALIDITY 0x0020 + #define ALL_CRC_PASS_FLAG 0x0040 + #define COM_PA_HOT_FLAG 0x0080 + #define COM_PA_OC_FLAG 0x8000 + #define COM_TX_FLAG 0x0100 + #define COM_SESSION_TIMEOUT_FLAG 0x0200 + #define COM_AUTO_POWER_OFF_BAE_FLAG 0x0400 + #define BAE_SW_EN_FLAG 0x0800 + #define RF_SW_STATUS_FLAG 0x1000 + #define COM_INIT_STATUS_FLAG 0x2000 + #define COM_TX_STATUS_FLAG 0x4000 + +//RF relay STATUS + #define RF_COM_TX 0 + #define RF_BCN 1 + +// COM_MNG_TMTC THREAD + #define SESSION_TIME_LIMIT 1500 + #define COM_RX_DISABLE_TIMEOUT 10 + #define COM_MNG_TMTC_SIGNAL_UART_INT 0x01 + #define COM_MNG_TMTC_SIGNAL_ADF_NSD 0x02 + #define COM_MNG_TMTC_SIGNAL_ADF_SD 0x03 + #define SCIENCE_SIGNAL 0x04 +// COM_MNG_TMTC + #define COM_PA_COOLING_TIME_LIMIT 20 + #define COM_MAX_TC_LIMIT 256 + #define TM_ACK_CODE_INDEX 2 + #define CRC_FAIL_NACK_CODE 0x01 + + // call sign + #define PSC_CALLSIGN 0x00 + #define APID_CALLSIGN 0x00 + + // max value of telecommands in a tcl + #define TCL_OVERFLOW_CONSTANT 256 + #define TM_OVERFLOW_CONSTANT 256 + #define BYTE_OVERFLOW_CONSTANT 35000 + + // starting value of packet sequence count at each pass + #define PSC_START_VALUE 1 + + // APID list + #define APID_COM 0 + #define APID_BAE 1 + #define APID_CDMS 2 + #define APID_SPEED 3 + + //SERVICE + #define SERVICE_OBOSC 0xB + #define SERVICE_OBSRS 0xF + + // HIGH PRIORITY TC - priority list + // not correct values here + #define HPTC1 5 + #define HPTC2 6 + // Add more entries above + + // SIZE of tc in bytes + #define TC_SHORT_SIZE 11 + #define TC_LONG_SIZE 135 + + // TMID list + #define TMID_ACK_L1 0xA + #define TMID_ACK_L234 0xB + #define TMID_TCL 0x7 + #define TMID_CALL_SIGN 0xE + +// OBOSC SERVICE SUBTYPE + #define OBOSC_TCL_MAX_SHORT_SIZE 11 + #define OBOSC_LONG_TC_FIRST_HALF_SIZE 67 + #define OBOSC_LONG_TC_SECOND_HALF_SIZE 68 + #define OBOSC_TCL_TAG_LONG_FIRST_HALF 0x10 + #define OBOSC_TCL_TAG_LONG_SECOND_HALF 0x11 + + #define OBOSC_SUB_DISABLE 0x01 + #define OBOSC_SUB_RETRY 0x05 + #define OBOSC_SUB_REP_TCLD 0x06 + #define OBOSC_SUB_REP_LE 0x0F + #define OBOSC_SUB_RESET 0x07 + +// PAYLOAD or SCIENCE + #define PAYLOAD_BUFFER_LENGTH 6723 + #define PAY_SPI_MOSI PTE18 + #define PAY_SPI_MISO PTE19 + #define PAY_SPI_CLK PTE17 + #define PAY_SPI_CS PTE16 + +//BEACON + #define BCN_APID_SOURCE 0x41 + #define BCN_SERVICE 0x81 + +//BAE + #define BAE_APID_SOURCE 0x81 + #define BAE_SERVICE 0x81 + #define BAE_POWER_ON_PID 0x13 + #define BAE_POWER_OFF_PID 0x23 + #define BAE_RESET_PID 0x33 + +//RF RELAY + #define RF_RELAY_CNTRL_TX PTA7 + #define RF_RELAY_CNTRL_BCN PTA12 + + +// ****************GLOBAL VARIABLES****************** +// DEBUG +Serial gPC( USBTX, USBRX ); +DigitalOut gLEDR(LED_RED); +DigitalOut gLEDG(LED_GREEN); + +// COM_RX +RawSerial RX1M( COM_RX_UART_TX, COM_RX_UART_RX ); +COM_RX_DATA_NODE *gRX_HEAD_DATA_NODE = NULL; +COM_RX_DATA_NODE *gRX_CURRENT_DATA_NODE = NULL; +// uint8_t *gRX_CURRENT_PTR = NULL; +uint32_t gRX_COUNT = 0; +uint16_t gTOTAL_RAW_BYTES = 0; +uint16_t gTOTAL_INCORRECT_SIZE_TC = 0x00; +uint16_t gTOTAL_CRC_FAIL_TC = 0x00; +uint16_t gTOTAL_REPEATED_TC = 0x00; + +// COMMON SPI +SPI spi( SPI_MOSI, SPI_MISO, SPI_CLK ); +DigitalOut gCS_ADF(SPI_CS_ADF); +DigitalOut cs_sd(SPI_CS_SDC); +DigitalOut gCS_RTC(SPI_CS_RTC); +Mutex SPI_mutex; + +//I2C +Mutex BAE_I2C_mutex; + +//RF Relay +DigitalOut RF_SW_CNTRL_BCN(RF_RELAY_CNTRL_BCN); +DigitalOut RF_SW_CNTRL_TX(RF_RELAY_CNTRL_TX); + +//COM_RX +DigitalOut COM_RX_CNTRL(PIN72); +DigitalOut COM_TX_CNTRL(PIN56); + +// TC LIST +Base_tc* gHEAD_NODE_TCL = NULL; +Base_tc* gLAST_NODE_TCL = NULL; +uint8_t gMASTER_STATE = TCL_STATE_INCOMPLETE; +uint16_t gFLAGS = 0x0000; + +// COM_MNG_TMTC THREAD +Thread* gCOM_MNG_TMTC_THREAD = NULL; +Timeout gRX_TIMEOUT; +Timeout gSESSION_TIMEOUT; +Timeout gCOM_RX_DISABLE; + +// COM_MNG_TMTC + + + +// PA cooling timeout +Timeout gCOM_PA_COOLING_TIMEOUT; + +// GS code for verification +const uint8_t gGSCODE[] = {0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; + +uint8_t gTOTAL_VALID_TC = 0x00; +// USE LAST_L1_ACK FOR GENERATING REPORT +uint8_t gLAST_TM[TM_LONG_SIZE]; +uint8_t gLAST_TM_SHORT_OR_LONG = SHORT_TM_CODE; + +// PAYLOAD OR SCIENCE_THREAD +Thread* gSCIENCE_THREAD = NULL; +dmaSPISlave gPAY_SPI(PAY_SPI_MOSI, PAY_SPI_MISO, PAY_SPI_CLK, PAY_SPI_CS); +uint8_t gPAYLOAD_BUFFER[PAYLOAD_BUFFER_LENGTH] = {0x00,0x00,0x00,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x00,0x00,0x41,0x00,0x00,0x00,0x41}; +RtosTimer *PL_wo_dma; + + +// CALL SIGN TM +const uint8_t gCALL_SIGN_STRING[TM_SHORT_SIZE] = {0xE0, 0x00, 0x00, 0x00, 0x56, 0x55, 0x32, 0x4E, 0x43, 0x46, 0x00, 0xAC, 0x11}; + +// CDMS HK +uint8_t CDMS_STANDBY; +uint8_t CDMS_HEALTH_DATA[128]; +uint8_t CDMS_RAM[59]; +uint16_t GPIO_STATUS; +uint8_t CDMS_HK_MAIN_STATUS; +uint8_t COMRX_STATUS; +uint8_t RTC_FAULTCOUNT; +uint16_t SD_FAULTCOUNT; +uint8_t SD_STATUS; +uint8_t BAE_FAULTCOUNT; +uint8_t BAE_STATUS; +uint8_t PL_STATUS; +uint16_t PL_FAULTCOUNT; +bool BAE_HK_I2C; +uint8_t RTC_STATUS; +float RSSI_volatge; + +CDMS_HK_actual actual_data; +CDMS_HK_quant quant_data; +CDMS_HK_min_max min_max_data; +bool firstCount=true; + +//GPIO PINS +DigitalIn V_A_PGOOD (PIN88); +DigitalIn V_B_PGOOD_1 (PIN6); +DigitalIn V_B_PGOOD_2 (PIN7); +DigitalIn V_C_PGOOD (PIN54); +DigitalIn COMRX_OC_FAULT (PIN68); +DigitalIn COMTX_OC_FAULT (PIN69); +DigitalIn BAE_OC_FAULT (PIN92); +DigitalIn PL_GPIO_1_STATUS (PIN71); +DigitalIn PL_GPIO_2_STATUS (PIN81); +DigitalIn PL_GPIO_3_STATUS (PIN80); +DigitalIn PL_BEE_SW_OC_FAULT (PIN4); +DigitalIn PL_EPS_LATCH_SW_OC_FAULT (); +DigitalIn V_C_EN_STATUS (); +DigitalIn V_D_EN_STATUS (); + + +DigitalIn SD_OC_FAULT (PIN90); +DigitalOut SD_SW_EN_DS (PIN97); +DigitalOut BAE_SW_EN_DS (PIN47); +DigitalOut PL_SW_EN_DS (PIN73); + +//SD HK +uint32_t FSC_CURRENT[6]; +uint32_t FSC_LAST[6]; +uint8_t SD_RD_ERROR; + +//Time's +uint32_t TIME_LATEST_RTC; +uint32_t TIME_LATEST_I2C_BAE; +uint32_t TIME_LATEST_I2C_SPEED; +uint32_t TIME_LATEST_SD_WR; +uint32_t TIME_LATEST_SD_RD; +uint32_t TIME_LATEST_SPI_SPEED; + +//Counter's +uint16_t CDMS_I2C_ERR_SPEED_COUNTER; +uint16_t CDMS_I2C_ERR_BAE_COUNTER; +uint16_t CDMS_HK_MAIN_COUNTER; +uint16_t COMRX_RESET_COUNTER; +uint16_t PL_MAIN_COUNTER; +uint16_t PL_RCV_SC_DATA_COUNTER; + +//CDMS RAM parameters +uint8_t PL_INIT_STATUS; +uint8_t PL_MAIN_STATUS; +uint8_t PL_LOW_POWER; +uint8_t PL_STATE; +uint8_t PL_RCV_SC_DATA_STATUS; +uint8_t COM_SESSION; +uint8_t COM_RX; +uint8_t RF_SW_STATUS; +uint8_t COM_TX; +uint8_t COM_TX_STATUS; +uint8_t COM_MNG_TMTC; +uint8_t CDMS_STANDBY_HK; +uint8_t CDMS_STANDBY_PL; +uint8_t CDMS_INIT_STATUS; +uint8_t CDMS_HK_STATUS; +uint8_t CDMS_RTC_BL; \ No newline at end of file
--- a/FMS_all.h Sun Jul 03 09:26:42 2016 +0000 +++ b/FMS_all.h Sun Jul 03 09:47:05 2016 +0000 @@ -20,6 +20,7 @@ void RST_PL_BEE(); void RST_HK_COUNTER(); uint8_t CDMS_RD_SD_HK(uint8_t *); +void RESET_CDMS(); void CDMS_INTERNAL_RESET(); void P_PL_INIT() @@ -150,7 +151,12 @@ return ACK; } +void RESET_CDMS() +{ + +} + void CDMS_INTERNAL_RESET() { - + } \ No newline at end of file
--- a/Flash.h Sun Jul 03 09:26:42 2016 +0000 +++ b/Flash.h Sun Jul 03 09:47:05 2016 +0000 @@ -4,6 +4,70 @@ uint32_t flasharray[256+(3*1024)]; char *nativeflash = (char*)strt_add; +/*Initiation of Flash*/ +void FLASH_INIT() +{ + uint32_t read[8]; + for(int i=0;i<8;i++) + { + read[i] = FCTN_CDMS_RD_FLASH(i); + //printf("\n\r val is read after starting %x ",read[i]); + } + + if(read[0] == -1) + for(int j=0;j<8;j++) + { + FCTN_CDMS_WR_FLASH(j,ARR_INITIAL_VAL[j]); + } + else + { + for(int j=0;j<8;j++) + { + read[j] = FCTN_CDMS_RD_FLASH(j); + } + ACS_ATS_STATUS = read[0]>>24; + ACS_TR_XY_SW_STATUS = ((uint8_t)(read[0]>>22))&0x03; + ACS_TR_Z_SW_STATUS = (read[0]>>20)&0x03; + ACS_DETUMBLING_ALGO_TYPE = (read[0]>>19)&0x01; + ACS_STATE = (read[0]>>16)&0x07; + BCN_TX_SW_STATUS = ((uint8_t)(read[0]>>14))&0x03; + BCN_SPND_TX = ((uint8_t)(read[0]>>13))&0x01; + BCN_FEN = ((uint8_t)(read[0]>>12))&0x01; + BCN_LONG_MSG_TYPE = ((uint8_t)(read[0]>>11))&0x01; + EPS_BTRY_HTR_AUTO = ((uint8_t)(read[0]>>10))&0x03;//EPS_BATTERY_HEATER_ENABLE + //now two spares in telemetry[5] + + //updating the reset counter + BAE_RESET_COUNTER = ((uint8_t)(read[0]))+1; + read[0]=(read[0]&0xffffff00) | (uint32_t)BAE_RESET_COUNTER; + FCTN_CDMS_WR_FLASH(0,read[0]); + + + EPS_SOC_LEVEL_12 = (uint8_t)(read[1]>>24); + EPS_SOC_LEVEL_23 = (uint8_t)(read[1]>>16); + ACS_MAG_TIME_DELAY = (uint8_t)(read[1]>>8); + ACS_DEMAG_TIME_DELAY = (uint8_t)read[1]; + + EPS_BAT_TEMP_LOW = (uint8_t)(read[2]>>24); + EPS_BAT_TEMP_HIGH = (uint8_t)(read[2]>>16); + EPS_BAT_TEMP_DEFAULT = (uint8_t)(read[2]>>8); + + ACS_MM_X_COMSN = (uint16_t)(read[3]>>16); + ACS_MM_Y_COMSN = (uint16_t)read[3]; + + ACS_MG_X_COMSN = (uint16_t)(read[4]>>16); + ACS_MG_Y_COMSN = (uint16_t)read[4]; + + ACS_MM_Z_COMSN = (uint16_t)(read[5]>>16); + ACS_MG_Z_COMSN = (uint16_t)read[5]; + + ACS_Z_FIXED_MOMENT = (uint16_t)(read[6]>>16);//assignvalues + + } + +} + + /*Writing to the Flash*/ void FCTN_CDMS_WR_FLASH(uint16_t j,uint32_t block) { @@ -15,7 +79,6 @@ erase_sector(strt_add); program_flash(strt_add, (char*)&flasharray,4*(256+(1024*3))); } -/*End*/ /*Reading from Flash*/ uint32_t FCTN_CDMS_RD_FLASH(uint16_t j)
--- a/P_COM_INIT.h Sun Jul 03 09:26:42 2016 +0000 +++ b/P_COM_INIT.h Sun Jul 03 09:47:05 2016 +0000 @@ -4,7 +4,7 @@ Thread::wait(25);\ RF_SW_CNTRL_BCN = 0;\ gFLAGS = gFLAGS | RF_SW_STATUS_FLAG;\ - COM_RX_CNTRL = 0;\ + //COM_RX_CNTRL = 0;\ Thread::wait(200);\ COM_RX_CNTRL = 1;\ gFLAGS = gFLAGS & (~COM_INIT_STATUS_FLAG);\
--- a/RESET_functions.h Sun Jul 03 09:26:42 2016 +0000 +++ b/RESET_functions.h Sun Jul 03 09:47:05 2016 +0000 @@ -8,6 +8,7 @@ pwr_comrx = 0; wait_ms(10); pwr_comrx =1; + COMRX_RESET_COUNTER++; } void RESET_RTC()
--- a/Structures.h Sun Jul 03 09:26:42 2016 +0000 +++ b/Structures.h Sun Jul 03 09:47:05 2016 +0000 @@ -27,9 +27,8 @@ 0: unexecuted 1: successfully executed 2: Execution Failed -3: CRC error -4: Disabled -5: Marked For retry +3: Disabled +4: Marked For retry */ #define TC_STATE_UNEXECUTED 0x00 #define TC_STATE_SUCCESSFULLY_EXECUTED 0x01
--- a/ThreadsAndFunctions.h Sun Jul 03 09:26:42 2016 +0000 +++ b/ThreadsAndFunctions.h Sun Jul 03 09:47:05 2016 +0000 @@ -36,12 +36,6 @@ gCOM_MNG_TMTC_THREAD->signal_set(COM_MNG_TMTC_SIGNAL_UART_INT); } -// COM_RX_DISABLE ISR -void after_com_disable(){ - gCOM_RX_DISABLE.detach(); - RX1M.attach(&rx_read, Serial::RxIrq); -} - // RX_TIMEOUT ISR void after_receive(){ gRX_TIMEOUT.detach(); @@ -69,15 +63,15 @@ }\ gHEAD_NODE_TCL = NULL;\ gLAST_NODE_TCL = NULL;\ - gMASTER_STATE = TCL_STATE_COMPLETED;\ + gMASTER_STATE = TCL_STATE_INCOMPLETE;\ gTOTAL_INCORRECT_SIZE_TC = 0;\ gTOTAL_CRC_FAIL_TC = 0;\ gTOTAL_REPEATED_TC = 0;\ gTOTAL_VALID_TC = 0;\ for(int i = 0 ; i < TM_LONG_SIZE ; ++i){\ - /*gLAST_TM[i] = 0x00;*/\ + gLAST_TM[i] = 0x00;\ }\ - /*gLAST_TM_SHORT_OR_LONG = SHORT_TM_CODE;*/\ + gLAST_TM_SHORT_OR_LONG = SHORT_TM_CODE;\ COM_RX_DATA_NODE *dataptr = gRX_HEAD_DATA_NODE;\ while( dataptr != NULL ){\ COM_RX_DATA_NODE *temp = dataptr->next_node;\ @@ -88,7 +82,6 @@ gRX_HEAD_DATA_NODE->next_node = NULL;\ gRX_CURRENT_DATA_NODE = gRX_HEAD_DATA_NODE;\ gRX_COUNT = 0;\ - gTOTAL_RAW_BYTES = 0;\ /*PENDING : ALL GLOBAL VAARIABLES AND FLAGS*/\ /*gPC.puts("finished reset all\r\n");*/\ } @@ -103,7 +96,6 @@ gRX_CURRENT_DATA_NODE = gRX_CURRENT_DATA_NODE->next_node;\ gRX_CURRENT_DATA_NODE->next_node = NULL;\ }\ - ++gTOTAL_RAW_BYTES;\ gRX_TIMEOUT.attach(&after_receive, RX_TIMEOUT_LIMIT);\ } @@ -118,12 +110,10 @@ gFLAGS = gFLAGS & (~UART_INT_FLAG); if( !(gFLAGS & COM_SESSION_FLAG) ){ // PENDING : DISABLE THREADS - // gCDMS_HK_TIMER.stop(); PL_wo_dma->stop(); gFLAGS = gFLAGS | COM_SESSION_FLAG; gSESSION_TIMEOUT.attach(&after_session, SESSION_TIME_LIMIT); gFLAGS = gFLAGS | COM_RX_FLAG; - gTOTAL_RAW_BYTES = 0; PUT_RAW_BYTE; // PENDING : MEASURE RSSI if( gFLAGS & COM_SESSION_FLAG ){ @@ -142,15 +132,10 @@ gFLAGS = gFLAGS | COM_RX_FLAG; PUT_RAW_BYTE; } - if(gTOTAL_RAW_BYTES > BYTE_OVERFLOW_CONSTANT){ - RX1M.attach(NULL); - gCOM_RX_DISABLE.attach(&after_com_disable, COM_RX_DISABLE_TIMEOUT); - after_receive(); - } } else if( gFLAGS & NEW_TC_RECEIVED ){ gPC.puts("NEW TC RECEIVED\r\n"); - Thread::wait(1000);/*For testing with transmitter. To be removed later*/ + Thread::wait(1000); gFLAGS = gFLAGS & (~NEW_TC_RECEIVED); gFLAGS = gFLAGS | COM_MNG_TMTC_RUNNING_FLAG; @@ -178,24 +163,30 @@ // CHECK WEATHER GS VERIFICATION CODE MATCHES uint8_t tempGSver = 0x00; GScodeVerification(tempGSver); + /*PENDING: INCLUDE GS VERIFICATION CODE*/ if( tempGSver == 0xFF ){ /*gPC.puts("GS code match !!\r\n");*/ gFLAGS = gFLAGS | COM_SESSION_VALIDITY; COM_POWER_ON_TX; - P_COM_HK; - if( (gFLAGS & COM_PA_HOT_FLAG) || ( gFLAGS & COM_PA_OC_FLAG ) ){ - COM_TX_CNTRL = 0; + // PENDING: PA HOT HANDLED IN EXECUTE_XXX FUNCTIONS + uint8_t tempPAHot = 0x00; + isPAhot(tempPAHot); + if( tempPAHot == 0xFF ){ + gFLAGS = gFLAGS & ~(COM_PA_HOT_FLAG); + gCOM_PA_COOLING_TIMEOUT.detach(); + gPC.puts("EXECUTING TELECOMMANDS\r\n"); +// DEBUF_PRINT("EXECUTING TELECOMMANDS\r\n"); + EXECUTE_OBOSC_ONLY; + EXECUTE_TC; + gPC.puts("COMPLETED EXECUTION\r\n"); + } + else{ + gFLAGS = gFLAGS | COM_PA_HOT_FLAG; + // PENDING: power off transmitter only gCOM_PA_COOLING_TIMEOUT.attach(&after_cooling_pa, COM_PA_COOLING_TIME_LIMIT); gFLAGS = gFLAGS & (~COM_MNG_TMTC_RUNNING_FLAG); RX1M.attach(&rx_read, Serial::RxIrq); } - else{ - gCOM_PA_COOLING_TIMEOUT.detach(); - gPC.puts("EXECUTING TELECOMMANDS\r\n"); - EXECUTE_OBOSC_ONLY; - EXECUTE_TC; - gPC.puts("COMPLETED EXECUTION\r\n"); - } } else{ /*gPC.puts("GS code mismatch !!\r\n");*/ @@ -203,11 +194,10 @@ reset_all; gFLAGS = gFLAGS & (~COM_SESSION_VALIDITY); // PENDING : ENABLE THREADS - // gCDMS_HK_TIMER.start(5000); PL_wo_dma->start(6000); gSESSION_TIMEOUT.detach(); gFLAGS = gFLAGS & (~COM_SESSION_FLAG); - gFLAGS = gFLAGS & (~COM_MNG_TMTC_RUNNING_FLAG); + // WARNING: clear COM_MNG_TMTC ? } } else{ @@ -238,16 +228,15 @@ } //gPC.puts("\r\n"); COM_POWER_ON_TX; - COM_TX_CNTRL = 0; + // PENDING : POWER OFF TX RX1M.attach(&rx_read, Serial::RxIrq); gFLAGS = gFLAGS & (~COM_MNG_TMTC_RUNNING_FLAG); } } else{ COM_POWER_ON_TX; - COM_TX_CNTRL = 0; - reset_all; - gFLAGS = gFLAGS & (~COM_SESSION_FLAG); + // POWER OFF TX transmitter only + // WARNING: reset_all ? clear com_session ? RX1M.attach(&rx_read, Serial::RxIrq); gFLAGS = gFLAGS & (~COM_MNG_TMTC_RUNNING_FLAG); } @@ -258,7 +247,6 @@ gFLAGS = gFLAGS & (~COM_MNG_TMTC_RUNNING_FLAG); reset_all; // PENDING : ENABLE THREADS - // gCDMS_HK_TIMER.start(5000); PL_wo_dma->start(6000); gSESSION_TIMEOUT.detach(); gFLAGS = gFLAGS & (~COM_SESSION_FLAG); @@ -266,17 +254,29 @@ } else if( gFLAGS & COM_PA_HOT_FLAG ){ /*gPC.puts("checking for PA hot in main\r\n");*/ - P_COM_HK; - if((gFLAGS & COM_PA_HOT_FLAG) || (gFLAGS & COM_PA_OC_FLAG)){ - COM_TX_CNTRL = 0; - gCOM_PA_COOLING_TIMEOUT.attach(&after_cooling_pa, COM_PA_COOLING_TIME_LIMIT); + if( gFLAGS & COM_RX_FLAG ){ + uint8_t tempPA = 0xFF; + isPAhot(tempPA); + if( tempPA == 0x00 ){ + gCOM_PA_COOLING_TIMEOUT.attach(&after_cooling_pa, COM_PA_COOLING_TIME_LIMIT); + } + else{ + gFLAGS = gFLAGS & ~(COM_PA_HOT_FLAG); + gCOM_PA_COOLING_TIMEOUT.detach(); + } } else{ - gCOM_PA_COOLING_TIMEOUT.detach(); - if( !(gFLAGS & COM_RX_FLAG) ){ + uint8_t tempPA = 0xFF; + isPAhot(tempPA); + if( tempPA == 0x00 ){ + gCOM_PA_COOLING_TIMEOUT.attach(&after_cooling_pa, COM_PA_COOLING_TIME_LIMIT); + } + else{ /*gPC.puts("PA IS COOLED DOWN\r\n");*/ + gFLAGS = gFLAGS & (~COM_PA_HOT_FLAG); gFLAGS = gFLAGS | COM_MNG_TMTC_RUNNING_FLAG; RX1M.attach(NULL); + gCOM_PA_COOLING_TIMEOUT.detach(); COM_POWER_ON_TX; EXECUTE_OBOSC_ONLY; EXECUTE_TC; @@ -287,7 +287,7 @@ /*gPC.puts("session timeout: resetting in main\r\n");*/ COM_POWER_OFF_TX; /*PENDING : ENABLE THREADS*/ - // gCDMS_HK_TIMER.start(5000); + gSESSION_TIMEOUT.detach(); gFLAGS = gFLAGS & (~COM_MNG_TMTC_RUNNING_FLAG); gFLAGS = gFLAGS & (~COM_SESSION_FLAG);
--- a/cdms_rtc.h Sun Jul 03 09:26:42 2016 +0000 +++ b/cdms_rtc.h Sun Jul 03 09:47:05 2016 +0000 @@ -1,5 +1,9 @@ void FCTN_CDMS_INIT_RTC() { + if(RTC_INIT_STATUS = 1) + { + + } SPI_mutex.lock(); gCS_RTC=1; spi.format(8,0); @@ -82,11 +86,16 @@ { SPI_mutex.lock(); uint8_t response; - + uint64_t time = 0; + gCS_RTC=1; gCS_RTC=0; spi.write(0x0F); response = (spi.write(0x00))&0x04; + if(response == 0x04) + { + goto END; + } gCS_RTC=1; gCS_RTC=0; @@ -116,7 +125,6 @@ year = (year == 17)?0x00:(year == 18)?0x01:(year == 19)?0x02:(year == 20)?0x03:0x00; gCS_RTC=1; - uint64_t time; time = 0; time = time|(((uint64_t)(centiseconds&0x7F))); time = time|(((uint64_t)(seconds&0x3F))<<7); @@ -128,6 +136,8 @@ time = (time&0x00000007FFFFFFFF); SPI_mutex.unlock(); + TIME_LATEST_RTC = time >> 7; + END: return time; }
--- a/cdms_sd.h Sun Jul 03 09:26:42 2016 +0000 +++ b/cdms_sd.h Sun Jul 03 09:47:05 2016 +0000 @@ -1,4 +1,4 @@ -//SPI spi(PTE1, PTE3, PTE2); // MOSI,MISO, CLOCK microcontroller(in order) +//SPI spi(PTE1, PTE3, PTE2); // MOSI,MISO, CLOCK microcontroller(in order) //DigitalOut cs_sd(PTE22); //Serial sd1(USBTX,USBRX); @@ -67,7 +67,7 @@ uint64_t sectors; int FCTN_CDMS_SD_INIT() -{ +{ int i = initialise_card(); debug_if(SD_DBG, "init card = %d\n", i); sectors = sd_sectors(); @@ -77,7 +77,7 @@ debug("\rSet 512-byte block timed out\r\n"); return 1; } else { - //printf("\rDisk initialization successfull\r\n"); + //printf("\rDisk initialization successfull\r\n"); } spi.frequency(1000000); // Set to 1MHz for data transfer @@ -90,7 +90,7 @@ uint32_t start_fsc; uint8_t buffer[512]; int b=disk_read(buffer, SD_MNG_SECT); - + fsc=(uint32_t)(buffer[0]<<24)+(uint32_t)(buffer[1]<<16)+(uint32_t)(buffer[2]<<8)+(uint32_t)buffer[3]; start_fsc=(uint32_t)(buffer[4]<<24)+(uint32_t)(buffer[5]<<16)+(uint32_t)(buffer[6]<<8)+(uint32_t)buffer[7]; FSC_CURRENT[1] = fsc; @@ -126,8 +126,7 @@ SD_MNG_SECT += SD_LIB_WRITES/(int)0xFFFF; SD_LIB_WRITES = SD_LIB_WRITES%(int)0xFFFF; disk_read(buffer,SD_MNG_SECT); - if(sid==0x01) - { + if(sid==0x01) { fsc=(uint32_t)(buffer[0]<<24)+(uint32_t)(buffer[1]<<16)+(uint32_t)(buffer[2]<<8)+(uint32_t)buffer[3]; start_fsc=(uint32_t)(buffer[4]<<24)+(uint32_t)(buffer[5]<<16)+(uint32_t)(buffer[6]<<8)+(uint32_t)buffer[7]; fsc++; @@ -135,25 +134,22 @@ buffer[1]=(uint8_t) (fsc>>16 & 0xFF); buffer[2]=(uint8_t) (fsc>>8 & 0xFF); buffer[3]=(uint8_t) (fsc & 0xFF); - if(fsc > SD_SCP_LAST-SD_SCP_FIRST+1) - { + if(fsc > SD_SCP_LAST-SD_SCP_FIRST+1) { start_fsc = start_fsc+1; buffer[4]=(uint8_t) (start_fsc>>24 & 0xFF); buffer[5]=(uint8_t) (start_fsc>>16 & 0xFF); buffer[6]=(uint8_t) (start_fsc>>8 & 0xFF); buffer[7]=(uint8_t) (start_fsc & 0xFF); } - + i = disk_write(buffer,SD_MNG_SECT); - if(i == 0) - { + if(i == 0) { FSC_CURRENT[1] = fsc; FSC_LAST[1] = start_fsc; return i; - } + } } - if(sid==0x02) - { + if(sid==0x02) { fsc=(uint32_t)(buffer[8]<<24)+(uint32_t)(buffer[9]<<16)+(uint32_t)(buffer[10]<<8)+(uint32_t)buffer[11]; start_fsc=(uint32_t)(buffer[12]<<24)+(uint32_t)(buffer[13]<<16)+(uint32_t)(buffer[14]<<8)+(uint32_t)buffer[15]; fsc++; @@ -161,8 +157,7 @@ buffer[9]=(uint8_t) (fsc>>16 & 0xFF); buffer[10]=(uint8_t) (fsc>>8 & 0xFF); buffer[11]=(uint8_t) (fsc & 0xFF); - if(fsc > SD_SFF_AT_LAST-SD_SFF_AT_FIRST+1) - { + if(fsc > SD_SFF_AT_LAST-SD_SFF_AT_FIRST+1) { start_fsc = start_fsc+1; buffer[12]=(uint8_t) (start_fsc>>24 & 0xFF); buffer[13]=(uint8_t) (start_fsc>>16 & 0xFF); @@ -170,15 +165,13 @@ buffer[15]=(uint8_t) (start_fsc & 0xFF); } i = disk_write(buffer,SD_MNG_SECT); - if(i == 0) - { + if(i == 0) { FSC_CURRENT[2] = fsc; FSC_LAST[2] = start_fsc; return i; } } - if(sid==0x03) - { + if(sid==0x03) { fsc=(uint32_t)(buffer[16]<<24)+(uint32_t)(buffer[17]<<16)+(uint32_t)(buffer[18]<<8)+(uint32_t)buffer[19]; start_fsc=(uint32_t)(buffer[20]<<24)+(uint32_t)(buffer[21]<<16)+(uint32_t)(buffer[22]<<8)+(uint32_t)buffer[23]; fsc++; @@ -186,8 +179,7 @@ buffer[17]=(uint8_t) (fsc>>16 & 0xFF); buffer[18]=(uint8_t) (fsc>>8 & 0xFF); buffer[19]=(uint8_t) (fsc & 0xFF); - if(fsc > SD_SFF_BT_LAST-SD_SFF_BT_FIRST+1) - { + if(fsc > SD_SFF_BT_LAST-SD_SFF_BT_FIRST+1) { start_fsc = start_fsc+1; buffer[20]=(uint8_t) (start_fsc>>24 & 0xFF); buffer[21]=(uint8_t) (start_fsc>>16 & 0xFF); @@ -195,15 +187,13 @@ buffer[23]=(uint8_t) (start_fsc & 0xFF); } i = disk_write(buffer,SD_MNG_SECT); - if(i == 0) - { + if(i == 0) { FSC_CURRENT[3] = fsc; FSC_LAST[3] = start_fsc; return i; } } - if(sid==0x04) - { + if(sid==0x04) { fsc=(uint32_t)(buffer[24]<<24)+(uint32_t)(buffer[25]<<16)+(uint32_t)(buffer[26]<<8)+(uint32_t)buffer[27]; start_fsc=(uint32_t)(buffer[28]<<24)+(uint32_t)(buffer[29]<<16)+(uint32_t)(buffer[30]<<8)+(uint32_t)buffer[31]; fsc++; @@ -211,8 +201,7 @@ buffer[25]=(uint8_t) (fsc>>16 & 0xFF); buffer[26]=(uint8_t) (fsc>>8 & 0xFF); buffer[27]=(uint8_t) (fsc & 0xFF); - if(fsc > SD_HK_ARCH_LAST-SD_HK_ARCH_FIRST+1) - { + if(fsc > SD_HK_ARCH_LAST-SD_HK_ARCH_FIRST+1) { start_fsc = start_fsc+1; buffer[28]=(uint8_t) (start_fsc>>24 & 0xFF); buffer[29]=(uint8_t) (start_fsc>>16 & 0xFF); @@ -220,15 +209,13 @@ buffer[31]=(uint8_t) (start_fsc & 0xFF); } i = disk_write(buffer,SD_MNG_SECT); - if(i == 0) - { + if(i == 0) { FSC_CURRENT[4] = fsc; FSC_LAST[4] = start_fsc; return i; } } - if(sid==0x05) - { + if(sid==0x05) { fsc=(uint32_t)(buffer[32]<<24)+(uint32_t)(buffer[33]<<16)+(uint32_t)(buffer[34]<<8)+(uint32_t)buffer[35]; start_fsc=(uint32_t)(buffer[36]<<24)+(uint32_t)(buffer[37]<<16)+(uint32_t)(buffer[38]<<8)+(uint32_t)buffer[39]; fsc++; @@ -236,8 +223,7 @@ buffer[33]=(uint8_t) (fsc>>16 & 0xFF); buffer[34]=(uint8_t) (fsc>>8 & 0xFF); buffer[35]=(uint8_t) (fsc & 0xFF); - if(fsc > LOG_LAST-LOG_FIRST+1) - { + if(fsc > LOG_LAST-LOG_FIRST+1) { start_fsc = start_fsc+1; buffer[36]=(uint8_t) (start_fsc>>24 & 0xFF); buffer[37]=(uint8_t) (start_fsc>>16 & 0xFF); @@ -245,8 +231,7 @@ buffer[39]=(uint8_t) (start_fsc & 0xFF); } i = disk_write(buffer,SD_MNG_SECT); - if(i == 0) - { + if(i == 0) { FSC_CURRENT[5] = fsc; FSC_LAST[5] = start_fsc; return i; @@ -260,61 +245,51 @@ { uint32_t block_number; int result = 10; - if(sid==0x01) - { + if(sid==0x01) { //block_number=SD_SCP_FIRST+(fsc%(SD_SCP_LAST-SD_SCP_FIRST+1))-1; block_number=SD_SCP_FIRST+fsc; result= disk_write(buffer,block_number); - if(result == 0) - { + if(result == 0) { if(INCREMENT_SD_LIB(sid) == 0) SD_LIB_WRITES++; } return result; } - if(sid==0x02) - { + if(sid==0x02) { //block_number= SD_SFF_AT_FIRST+(fsc%(SD_SFF_AT_LAST - SD_SFF_AT_FIRST+1))-1; block_number= SD_SFF_AT_FIRST+fsc; result= disk_write(buffer,block_number); - if(result == 0) - { + if(result == 0) { if(INCREMENT_SD_LIB(sid) == 0) SD_LIB_WRITES++; } return result; } - if(sid==0x03) - { + if(sid==0x03) { //block_number= SD_SFF_BT_FIRST +(fsc%(SD_SFF_BT_LAST - SD_SFF_BT_FIRST +1))-1; block_number= SD_SFF_BT_FIRST +fsc; result= disk_write(buffer,block_number); - if(result == 0) - { + if(result == 0) { if(INCREMENT_SD_LIB(sid) == 0) SD_LIB_WRITES++; } return result; } - if(sid==0x04) - { + if(sid==0x04) { //block_number=SD_HK_ARCH_FIRST +(fsc%(SD_HK_ARCH_LAST - SD_HK_ARCH_FIRST +1))-1; block_number=SD_HK_ARCH_FIRST +fsc; result= disk_write(buffer,block_number); - if(result == 0) - { + if(result == 0) { if(INCREMENT_SD_LIB(sid) == 0) SD_LIB_WRITES++; } return result; } - if(sid==0x05) - { + if(sid==0x05) { //block_number= LOG_FIRST +(fsc%(LOG_FIRST - LOG_FIRST +1))-1; block_number= LOG_FIRST +fsc; result= disk_write(buffer,block_number); - if(result == 0) - { + if(result == 0) { if(INCREMENT_SD_LIB(sid) == 0) SD_LIB_WRITES++; } @@ -330,48 +305,37 @@ int result; if(SD_SW_EN_DS == 1) return 0x89; - if(sid==0x01) - { - if(!(FSC_LAST[1]<=fsc && fsc<=FSC_CURRENT[1])){ + if(sid==0x01) { + if(!(FSC_LAST[1]<=fsc && fsc<=FSC_CURRENT[1])) { return 0x86; } block_number=SD_SCP_FIRST + fsc; result= disk_read(buffer,block_number); - } - else if(sid==0x02) - { - if(!(FSC_LAST[2]<=fsc && fsc<=FSC_CURRENT[2])){ + } else if(sid==0x02) { + if(!(FSC_LAST[2]<=fsc && fsc<=FSC_CURRENT[2])) { return 0x86; } block_number=SD_SFF_AT_FIRST + fsc; result= disk_read(buffer,block_number); - } - else if(sid==0x03) - { - if(!(FSC_LAST[3]<=fsc && fsc<=FSC_CURRENT[3])){ + } else if(sid==0x03) { + if(!(FSC_LAST[3]<=fsc && fsc<=FSC_CURRENT[3])) { return 0x86; } block_number=SD_SFF_BT_FIRST + fsc; result= disk_read(buffer,block_number); - } - else if(sid==0x04) - { - if(!(FSC_LAST[4]<=fsc && fsc<=FSC_CURRENT[4])){ + } else if(sid==0x04) { + if(!(FSC_LAST[4]<=fsc && fsc<=FSC_CURRENT[4])) { return 0x86; } block_number=SD_HK_ARCH_FIRST + fsc; result= disk_read(buffer,block_number); - } - else if(sid==0x05) - { - if(!(FSC_LAST[5]<=fsc && fsc<=FSC_CURRENT[5])){ + } else if(sid==0x05) { + if(!(FSC_LAST[5]<=fsc && fsc<=FSC_CURRENT[5])) { return 0x86; } block_number=LOG_FIRST +fsc; result= disk_read(buffer,block_number); - } - else - { + } else { return 0x02; } if(result == 0) @@ -384,7 +348,7 @@ int initialise_card() { // Set to 100kHz for initialisation, and clock card with cs_sd = 1 - spi.frequency(100000); // changed on 31 12 2015 to 1 MHz + spi.frequency(100000); // changed on 31 12 2015 to 1 MHz cs_sd = 1; for (int i = 0; i < 16; i++) { spi.write(0xFF); @@ -395,9 +359,8 @@ if (R1_response != R1_IDLE_STATE) { debug("No disk, or could not put SD card in to spi idle state\r\n"); return SDCARD_FAIL; - } - else - gPC.puts("SD Card is in IDLE state\n\r"); + } else + gPC.puts("SD Card is in IDLE state\n\r"); // send CMD8 to determine whther it is ver 2.x int r = cmd8(); @@ -643,13 +606,10 @@ if (cmd(24, block_number * cdv) != 0) { return 1; } - - uint64_t temp; + int r = write(buffer, 512); - if(r == 0 ){ - temp = FCTN_CDMS_RD_RTC(); - TIME_LATEST_SD_RD = temp >> 7; - } + if(r == 0 ) + TIME_LATEST_SD_WR = FCTN_CDMS_RD_RTC() >> 7; return r; } @@ -694,8 +654,7 @@ // receive the data read(buffer, 512); - uint64_t temp = FCTN_CDMS_RD_RTC(); - TIME_LATEST_SD_RD = temp >> 7; + TIME_LATEST_SD_RD = FCTN_CDMS_RD_RTC() >> 7; return 0; } @@ -729,14 +688,14 @@ if (cmd(38,0) != 0) { return 1; } - + return 0; //normal return } int disk_read_statusbits(uint8_t *buffer) { if (cmd(17, 0) != 0) { - SD_RD_ERROR = 1; + SD_RD_ERROR = 1; return -1; }
--- a/common_functions.h Sun Jul 03 09:26:42 2016 +0000 +++ b/common_functions.h Sun Jul 03 09:47:05 2016 +0000 @@ -77,7 +77,7 @@ }\ }\ else{\ - RESET_CDMS;\ + /*PENDING: reset cdms*/\ break;\ }\ }\ @@ -99,24 +99,18 @@ /*Attach this new node at the end*/\ }\ else{\ - RESET_CDMS;\ + /*PENDING: reset CDMS*/\ break;\ }\ }\ } #define put_crc_l1_ack(tm_ptr) {\ + tm_ptr->TM_string[2] = gTOTAL_CRC_FAIL_TC & 0xFF;\ /*TC LIST STATUS*/\ - tm_ptr->TM_string[3] |= (gMASTER_STATE << 6) & 0xC0;\ + tm_ptr->TM_string[3] |= (gMASTER_STATE << 5) & 0xE0;\ /*PA HOT*/\ if( gFLAGS & COM_PA_HOT_FLAG ){\ - tm_ptr->TM_string[3] |= (1 << 5);\ - }\ - else{\ - tm_ptr->TM_string[3] &= ~(1 << 5);\ - }\ - /*PA OC*/\ - if( gFLAGS & COM_PA_OC_FLAG ){\ tm_ptr->TM_string[3] |= (1 << 4);\ }\ else{\ @@ -130,39 +124,16 @@ #define fill_l1_ack(tm_ptr) {\ tm_ptr->next_TM = NULL;\ tm_ptr->TM_string[0] = TMID_ACK_L1 << 4;\ + /*PENDING: PA TEMPERATURE*/\ tm_ptr->TM_string[1] = gTOTAL_INCORRECT_SIZE_TC & 0xFF;\ tm_ptr->TM_string[2] = gTOTAL_CRC_FAIL_TC & 0xFF;\ } -#define P_COM_HK{\ - uint8_t returnHere;\ - isPAhot(returnHere);\ - if (returnHere == 0xFF)\ - gFLAGS = gFLAGS & ~(COM_PA_HOT_FLAG);\ - else\ - gFLAGS = gFLAGS | COM_PA_HOT_FLAG;\ - if (gFLAGS & COM_PA_OC_FLAG){\ - COM_TX_CNTRL = 1;\ - wait_ms(5);\ - }\ - isPAoc(returnHere);\ - if (returnHere == 0xFF)\ - gFLAGS = gFLAGS & ~(COM_PA_OC_FLAG);\ - else\ - gFLAGS = gFLAGS | COM_PA_OC_FLAG;\ - /*P_CDMS_HANDLE_HW_FAULTS*/\ -} - #define isPAhot(returnHere){\ /*PENDING : COMPLETE THIS FUNCTION*/\ returnHere = 0xFF;\ } -#define isPAoc(returnHere){\ - /*PENDING : COMPLETE THIS FUNCTION*/\ - returnHere = 0xFF;\ -} - #define get_call_sign(tm_ptr) {\ Base_tm* call_sign_tm = new Short_tm;\ call_sign_tm->next_TM = NULL;\ @@ -185,6 +156,7 @@ /*IF CRC PASS*/\ if( (GETcrc_pass(current_TC) == 1) ){\ if(TC_count > 4){\ + /*PENDING: FILL TC_EXEC_CODE, APPEND CRC TO THE TM*/\ put_crc_l1_ack( l1_ack );\ /*extend the TM linked list*/\ TC_count = 0;\ @@ -217,7 +189,7 @@ ++overflowCountL1;\ }\ else{\ - RESET_CDMS;\ + /*PENDING: RESET CDMS*/\ break;\ }\ }\
--- a/i2c.h Sun Jul 03 09:26:42 2016 +0000 +++ b/i2c.h Sun Jul 03 09:47:05 2016 +0000 @@ -26,29 +26,31 @@ I2C0->C1 |= 0x80; //Enabling I2C module PORTE->PCR[1] |= 0x00000004; //Disabling high slew rates for SDA and SCL lines PORTE->PCR[0] |= 0x00000004; //Disabling high slew rates for SDA and SCL lines - Thread::wait(1); //Wait for all I2C registers to be updates to their their values + wait_ms(1); //Wait for all I2C registers to be updates to their their values } bool FCTN_I2C_READ_PL(char *data,int length) // Returns 0 for success { PL_I2C_GPIO = 1; read_ack = master.read(addr_pl|1,data,length); - Thread::wait(1); //as per tests Thread::wait not required on master side. But its safe to give 1ms + wait_ms(1); //as per tests Thread::wait not required on master side. But its safe to give 1ms pdirr1=PTE->PDIR; uint8_t i2c_count = 0; if(read_ack == 0) //if read_ack says success, it may or may not be successful.Hence we check SCL and SDA { while(((pdirr1 & 0x03000000)!=0x03000000)&& i2c_count<10)//checking SCL and SDA for time=10ms { - Thread::wait(1); + wait_ms(1); pdirr1=PTE->PDIR; i2c_count++; } if(((pdirr1 & 0x03000000)==0x03000000))//if SCL and SDA are both high { - gPC.printf("\n\rData received from BAE"); + TIME_LATEST_I2C_SPEED = FCTN_CDMS_RD_RTC() >> 7; + gPC.printf("\n\rData received from PL"); } else - { + { + CDMS_I2C_ERR_SPEED_COUNTER++; I2C_busreset(); read_ack = 1; } @@ -65,23 +67,25 @@ bool FCTN_I2C_WRITE_PL(char *data2,uint8_t tc_len2) // Returns 0 for success { write_ack = master.write(addr_pl|0x00,data2,tc_len2);//address to be defined in payload - Thread::wait(1); //As per the tests Thread::wait is not required on master side but its safe to give 1ms + wait_ms(1); //As per the tests Thread::wait is not required on master side but its safe to give 1ms pdirw1=PTE->PDIR; uint8_t i2c_count = 0; if(write_ack == 0) { while(((pdirw1 & 0x03000000)!=0x03000000)&& i2c_count<10) { - Thread::wait(1); + wait_ms(1); pdirw1=PTE->PDIR; i2c_count++; } if(((pdirw1 & 0x03000000)==0x03000000)) { - gPC.printf("\n\r Data sent"); + TIME_LATEST_I2C_SPEED = FCTN_CDMS_RD_RTC() >> 7; + gPC.printf("\n\r Data sent to PL"); } else { + CDMS_I2C_ERR_SPEED_COUNTER++; I2C_busreset(); write_ack = 1; } @@ -97,23 +101,25 @@ { CDMS_I2C_GPIO = 1; read_ack = master.read(addr_bae|1,data,length); - Thread::wait(1); //as per tests Thread::wait not required on master side. But its safe to give 1ms + wait_ms(1); //as per tests Thread::wait not required on master side. But its safe to give 1ms pdirr1=PTE->PDIR; uint8_t i2c_count = 0; if(read_ack == 0) //if read_ack says success, it may or may not be successful.Hence we check SCL and SDA { while(((pdirr1 & 0x03000000)!=0x03000000)&& i2c_count<10)//checking SCL and SDA for time=10ms { - Thread::wait(1); + wait_ms(1); pdirr1=PTE->PDIR; i2c_count++; } if(((pdirr1 & 0x03000000)==0x03000000))//if SCL and SDA are both high { + TIME_LATEST_I2C_BAE = FCTN_CDMS_RD_RTC() >> 7; gPC.printf("\n\rData received from BAE"); } else - { + { + CDMS_I2C_ERR_BAE_COUNTER++; I2C_busreset(); read_ack = 1; } @@ -131,23 +137,25 @@ { CDMS_I2C_GPIO = 1; write_ack = master.write(addr_bae|0x00,data,tc_len2); - Thread::wait(1); //As per the tests Thread::wait is not required on master side but its safe to give 1ms + wait_ms(1); //As per the tests Thread::wait is not required on master side but its safe to give 1ms pdirw1=PTE->PDIR; uint8_t i2c_count = 0; if(write_ack == 0) { while(((pdirw1 & 0x03000000)!=0x03000000)&& i2c_count<10) { - Thread::wait(1); + wait_ms(1); pdirw1=PTE->PDIR; i2c_count++; } if(((pdirw1 & 0x03000000)==0x03000000)) { - gPC.printf("\n\r Data sent"); + TIME_LATEST_I2C_BAE = FCTN_CDMS_RD_RTC() >> 7; + gPC.printf("\n\r Data sent BAE"); } else { + CDMS_I2C_ERR_BAE_COUNTER++; I2C_busreset(); write_ack = 1; }
--- a/main.cpp Sun Jul 03 09:26:42 2016 +0000 +++ b/main.cpp Sun Jul 03 09:47:05 2016 +0000 @@ -1,7 +1,4 @@ - // TESTING PUSH PULL IN MAIN CPP - - #include "mbed.h" #define DEBUG 1 @@ -10,32 +7,34 @@ #include "dmaSPIslave.h" #include "rtos.h" #include "mbed_debug.h" -void rx_read(); + #include "Structures.h" #include "pinconfig.h" #include "DefinitionsAndGlobals.h" #include "crc.h" +#include "cdms_rtc.h" +#include "cdms_sd.h" #include "i2c.h" #include "COM_SND_TM_functions.h" #include "COM_SND_TM.h" -#include "cdms_rtc.h" -#include "cdms_sd.h" #include "common_functions.h" #include "RESET_functions.h" #include "CDMS_HK.h" +#include "OBSRS.h" #include "adf.h" #include "COM_RCV_TC.h" -//#include "Flash.h" +#include "Flash.h" #include "FMS_all.h" #include "CDMS_PL.h" #include "COM_MNG_TMTC.h" +#include "COM_POWER_ON_TX.h" #include "COM_POWER_OFF_TX.h" -#include "COM_POWER_ON_TX.h" -#include "OBSRS.h" #include "Compression.h" #include "ThreadsAndFunctions.h" #include "TEST_PL.h" +void CDMS_INIT(); + #define PL_TC(tm_ptr){\ Base_tc *beacon_tc = new Short_tc;\ beacon_tc->next_TC = NULL;\ @@ -84,108 +83,112 @@ transmit_adf;\ gPC.puts("exit_adf\r\n");\ } -//void set_sig(){gSCIENCE_THREAD->signal_set(SCIENCE_SIGNAL);} + +void CDMS_INIT() +{ + CDMS_INIT_STATUS = 1; + + spi.format(8,0); + spi.frequency(1000000); + + cs_sd = 1; + gCS_RTC = 1; + gCS_ADF = 1; + + FCTN_CDMS_INIT_RTC(); + FCTN_CDMS_SD_INIT(); + +} + int main() { - - CDMS_I2C_GPIO = 0; - PL_I2C_GPIO = 0; - - //gLEDR = 1; - + + CDMS_I2C_GPIO = 0; + PL_I2C_GPIO = 0; + // ******************INITIALISATIONS START****************** - // COM RX - + RX1M.baud(1200); gRX_HEAD_DATA_NODE = new COM_RX_DATA_NODE; gRX_HEAD_DATA_NODE->next_node = NULL; gRX_CURRENT_DATA_NODE = gRX_HEAD_DATA_NODE; gRX_COUNT = 0; -// gRX_CURRENT_PTR = gRX_CURRENT_DATA_NODE->values; + //gRX_CURRENT_PTR = gRX_CURRENT_DATA_NODE->values; RX1M.attach(&rx_read, Serial::RxIrq); - + // DEBUG //gPC.puts("welcome to mng_tm_tc\r\n"); gPC.baud(115200);//changed for bypassing COM - - // COMMON SPI - spi.format(8,0); - spi.frequency(1000000); + - // SD CARD - cs_sd = 1; - gCS_RTC = 1; - gCS_ADF = 1; - FCTN_CDMS_INIT_RTC();/* rtc initialization*/ - FCTN_CDMS_SD_INIT();/* sd card initialization*/ - - + + uint8_t test[512] = {0}; disk_write(test,7000); //to be used only just before launch - - #if DEBUG + +#if DEBUG gPC.puts("welcome to mng_tmtc\r\n"); - #endif - - - +#endif + + + // COM_MNG_TMTC THREAD gCOM_MNG_TMTC_THREAD = new Thread(COM_MNG_TMTC_FUN); gCOM_MNG_TMTC_THREAD->set_priority(osPriorityHigh); - #if DEBUG +#if DEBUG gPC.puts("allocating threads\r\n"); - #endif +#endif gSCIENCE_THREAD = new Thread(SCIENCE_FUN); - // gPC.puts("step one complete\r\n"); + // gPC.puts("step one complete\r\n"); gSCIENCE_THREAD->set_priority(osPriorityAboveNormal); - #if DEBUG +#if DEBUG gPC.puts("competed allocating threads\r\n"); - #endif - - +#endif + + master.frequency(400000); PL_wo_dma = new RtosTimer(payload_isr_fun_dma, osTimerPeriodic,(void * )NULL); //PL_wo_dma->start(6000);// gSCIENCE_THREAD->signal_set(SCIENCE_SIGNAL); - - - - + + + + /*gPC.printf("PL_TC sending\r\n"); - + Base_tm *tm_ptr = new Short_tm; OBSRS_TC(tm_ptr); - + gPC.printf("PL_TC sent"); */ // *******************INITIALISATIONS END******************** - + //RtosTimer gCDMS_HK_TIMER(FCTN_CDMS_HK_MAIN, osTimerPeriodic); //gCDMS_HK_TIMER.start(5000); - + /*starting the thread with signal*/ //set_sig(); //payload_isr_fun(); - + /*Calculating Stack used*/ - + int state; - /*while (true) { - Thread::wait(500); - state = gSCIENCE_THREAD->get_state(); - //gPC.printf("Thread state %d\r\n", state); - if(state == Thread::Inactive) + /*while (true) { + Thread::wait(500); + state = gSCIENCE_THREAD->get_state(); + //gPC.printf("Thread state %d\r\n", state); + if(state == Thread::Inactive) {delete gSCIENCE_THREAD; break;} }*/ - - - - while(true){ + + + + while(true) { Thread::wait(osWaitForever); //state = gCOM_MNG_TMTC_THREAD->get_state() + '0'; - gLEDG = !gLEDG; - //gPC.putc(state); + gLEDG = !gLEDG; + //gPC.putc(state); } } \ No newline at end of file