
Compression code changed and RLY_TMTC pointers managed
Dependencies: FreescaleIAP SimpleDMA mbed-rtos mbed
Fork of CDMS_CODE by
Revision 73:6c99294b7802, committed 2016-01-18
- Comitter:
- ee12b079
- Date:
- Mon Jan 18 22:21:23 2016 +0000
- Parent:
- 69:20f09a0c3fd2
- Child:
- 74:65a271b5cf17
- Child:
- 80:b2155ba726c3
- Commit message:
- Not tested
Changed in this revision
COM_MNG_TMTC.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/COM_MNG_TMTC.h Sun Jan 17 14:04:08 2016 +0000 +++ b/COM_MNG_TMTC.h Mon Jan 18 22:21:23 2016 +0000 @@ -36,24 +36,6 @@ delete tc_ptr;\ } -#define delete_all_tm(tm_ptr_head){\ - /*DELETE THE TM AFTER USE*/\ - Base_tm *temp_tm_ptr = tm_ptr_head;\ - int overflowCountExecute = 0;\ - while(temp_tm_ptr != NULL){\ - if( overflowCountExecute < TM_OVERFLOW_CONSTANT ){\ - Base_tm *temp = temp_tm_ptr->next_TM;\ - delete temp_tm_ptr;\ - temp_tm_ptr = temp;\ - ++overflowCountExecute;\ - }\ - else{\ - /*PENDING: RESET CDMS*/\ - break;\ - }\ - }\ -} - // typeof tm_ptr: Base_tm // typeof tc_ptr: Base_tc // typeof temp_xxxx: uint8_t @@ -427,7 +409,7 @@ // CDMS TEAM CODE START inline Base_tm* FCTN_CDMS_RLY_TMTC(Base_tc *tc_ptr){ uint8_t ACKCODE = 0x00; - //gPC.printf("\rTC execution in progress\r\n"); + //printf("\rTC execution in progress\r\n"); Base_tm *tm_pointer = new Long_tm; Base_tm *tm_ptr = tm_pointer; received = 0; @@ -435,17 +417,17 @@ { case 1: //apid=01 implies it corresponds to bae { - //gPC.printf("Telecommand is for BAE\r\n"); - //gPC.printf("Sending TC to BAE...\r\n"); //interrupt to be sent to the bae + //printf("Telecommand is for BAE\r\n"); + //printf("Sending TC to BAE...\r\n"); //interrupt to be sent to the bae FCTN_I2C_WRITE((char*)tc_ptr->TC_string); while(1) { wait(1); //TimeOut instead of wait if(tm_status_4m_slv == 1) { - //gPC.printf("receiving...\r\n"); + //printf("receiving...\r\n"); FCTN_I2C_READ((char*)tm_pointer->TM_string); - //gPC.printf("%s", tm_pointer->TM_string); + //printf("%s", tm_pointer->TM_string); received+=1; tm_pointer = tm_pointer->next_TM; break; //only for testing purpose @@ -457,11 +439,11 @@ } if(received >= 1 ) { - //gPC.printf("Telemetry is received from BAE\r\n"); + //printf("Telemetry is received from BAE\r\n"); Base_tm *tm_print = tm_ptr; for(uint8_t i=0;i<received;i++) { - //gPC.printf("%s", tm_print->TM_string); + //printf("%s", tm_print->TM_string); tm_print = tm_print->next_TM; //for check } received = 0; @@ -469,7 +451,7 @@ } else { - //gPC.printf("Telemetry is not received from BAE\r\n"); + //printf("Telemetry is not received from BAE\r\n"); //tm_pointer = new Short_tm; tm_pointer->TM_string[0] = 0xB0; tm_pointer->TM_string[1] = GETpacket_seq_count(tc_ptr); @@ -489,7 +471,7 @@ } case 2: { - //gPC.printf("Telecommand is for CDMS\r\n"); //apid = 10 corresponds to cdms + //printf("Telecommand is for CDMS\r\n"); //apid = 10 corresponds to cdms switch(GETservice_type(tc_ptr)) { case 0x60: @@ -499,7 +481,7 @@ { case 0x1: { - //gPC.printf("sub_service:Read from RAM_Memory\r\n"); + //printf("sub_service:Read from RAM_Memory\r\n"); mid=(uint16_t)(tc_ptr->TC_string[3]<<4)+(uint16_t)(tc_ptr->TC_string[4]); Data[0] = FCTN_CDMS_RD_FLASH(0); @@ -523,7 +505,7 @@ } case 0x2: { - //gPC.printf("sub_service:Read from Flash_Memory\r\n"); + //printf("sub_service:Read from Flash_Memory\r\n"); mid=(uint16_t)(tc_ptr->TC_string[3]<<4)+(uint16_t)(tc_ptr->TC_string[4]); Data[0] = FCTN_CDMS_RD_FLASH(0); @@ -547,7 +529,7 @@ } case 0x5: { - //gPC.printf("WRITE ON FLASH_MEMORY\r\n"); + //printf("WRITE ON FLASH_MEMORY\r\n"); mid=(uint16_t)(tc_ptr->TC_string[3]<<4)+(uint16_t)(tc_ptr->TC_string[4]); block = (((uint32_t)(tc_ptr->TC_string[5])<<24)|((uint32_t)(tc_ptr->TC_string[5])<<16)|((uint32_t)(tc_ptr->TC_string[5])<<8)|((uint32_t)(tc_ptr->TC_string[5]))); FCTN_CDMS_WR_FLASH(mid,block); @@ -569,7 +551,7 @@ } default: { - //gPC.printf("INVALID TC\r\n"); //Send Invalid TC Telemetry + //printf("INVALID TC\r\n"); //Send Invalid TC Telemetry //tm_pointer = new Short_tm; tm_pointer->TM_string[0] = 0xB0; tm_pointer->TM_string[1] = GETpacket_seq_count(tc_ptr); @@ -590,12 +572,12 @@ } case 0x8: { - //gPC.printf("service:FUNCTION MANAGEMENT SERVICE\r\n"); + //printf("service:FUNCTION MANAGEMENT SERVICE\r\n"); if(GETservice_subtype(tc_ptr)==0x1) { if(GETpid(tc_ptr)==0x01) { - //gPC.printf("TC_PL_INIT\r\n"); // call PWR_SWCH_ON function + //printf("TC_PL_INIT\r\n"); // call PWR_SWCH_ON function //tm_pointer = new Short_tm; tm_pointer->TM_string[0] = 0xB0; tm_pointer->TM_string[1] = GETpacket_seq_count(tc_ptr); @@ -612,7 +594,7 @@ } else if(GETpid(tc_ptr)==0x02) { - //gPC.printf("TC_PL_MAIN\r\n"); // call PWR_SWCH_ON function + //printf("TC_PL_MAIN\r\n"); // call PWR_SWCH_ON function //tm_pointer = new Short_tm; tm_pointer->TM_string[0] = 0xB0; tm_pointer->TM_string[1] = GETpacket_seq_count(tc_ptr); @@ -629,7 +611,7 @@ } else if(GETpid(tc_ptr)==0x03) { - //gPC.printf("TC_COM_INIT\r\n"); // call PWR_SWCH_ON function + //printf("TC_COM_INIT\r\n"); // call PWR_SWCH_ON function //tm_pointer = new Short_tm; tm_pointer->TM_string[0] = 0xB0; tm_pointer->TM_string[1] = GETpacket_seq_count(tc_ptr); @@ -646,7 +628,7 @@ } else if(GETpid(tc_ptr)==0x04) { - //gPC.printf("TC_CDMS_HK_MAIN\r\n"); // call PWR_SWCH_ON function + //printf("TC_CDMS_HK_MAIN\r\n"); // call PWR_SWCH_ON function //tm_pointer = new Short_tm; tm_pointer->TM_string[0] = 0xB0; tm_pointer->TM_string[1] = GETpacket_seq_count(tc_ptr); @@ -663,7 +645,7 @@ } else if(GETpid(tc_ptr)==0x11) { - //gPC.printf("TC_SW_ON_SD\r\n"); // call PWR_SWCH_ON function + //printf("TC_SW_ON_SD\r\n"); // call PWR_SWCH_ON function //tm_pointer = new Short_tm; tm_pointer->TM_string[0] = 0xB0; tm_pointer->TM_string[1] = GETpacket_seq_count(tc_ptr); @@ -680,7 +662,7 @@ } else if(GETpid(tc_ptr)==0x12) { - //gPC.printf("TC_SW_ON_RTC\r\n"); // call PWR_SWCH_ON function + //printf("TC_SW_ON_RTC\r\n"); // call PWR_SWCH_ON function //tm_pointer = new Short_tm; tm_pointer->TM_string[0] = 0xB0; tm_pointer->TM_string[1] = GETpacket_seq_count(tc_ptr); @@ -697,7 +679,7 @@ } else if(GETpid(tc_ptr)==0x13) { - //gPC.printf("TC_SW_ON_BAE\r\n"); // call PWR_SWCH_ON function + //printf("TC_SW_ON_BAE\r\n"); // call PWR_SWCH_ON function //tm_pointer = new Short_tm; tm_pointer->TM_string[0] = 0xB0; tm_pointer->TM_string[1] = GETpacket_seq_count(tc_ptr); @@ -714,7 +696,7 @@ } else if(GETpid(tc_ptr)==0x14) { - //gPC.printf("TC_SW_ON_PL_DL\r\n"); // call PWR_SWCH_ON function + //printf("TC_SW_ON_PL_DL\r\n"); // call PWR_SWCH_ON function //tm_pointer = new Short_tm; tm_pointer->TM_string[0] = 0xB0; tm_pointer->TM_string[1] = GETpacket_seq_count(tc_ptr); @@ -731,7 +713,7 @@ } else if(GETpid(tc_ptr)==0x15) { - //gPC.printf("TC_SW_ON_PL_AG_HV\r\n"); // call PWR_SWCH_ON function + //printf("TC_SW_ON_PL_AG_HV\r\n"); // call PWR_SWCH_ON function //tm_pointer = new Short_tm; tm_pointer->TM_string[0] = 0xB0; tm_pointer->TM_string[1] = GETpacket_seq_count(tc_ptr); @@ -748,7 +730,7 @@ } else if(GETpid(tc_ptr)==0x16) { - //gPC.printf("TC_SW_ON_V_A_EN\r\n"); // call PWR_SWCH_ON function + //printf("TC_SW_ON_V_A_EN\r\n"); // call PWR_SWCH_ON function //tm_pointer = new Short_tm; tm_pointer->TM_string[0] = 0xB0; tm_pointer->TM_string[1] = GETpacket_seq_count(tc_ptr); @@ -765,7 +747,7 @@ } else if(GETpid(tc_ptr)==0x21) { - //gPC.printf("TC_SW_OFF_SD\r\n"); // call PWR_SWCH_ON function + //printf("TC_SW_OFF_SD\r\n"); // call PWR_SWCH_ON function //tm_pointer = new Short_tm; tm_pointer->TM_string[0] = 0xB0; tm_pointer->TM_string[1] = GETpacket_seq_count(tc_ptr); @@ -782,7 +764,7 @@ } else if(GETpid(tc_ptr)==0x22) { - //gPC.printf("TC_SW_OFF_RTC\r\n"); // call PWR_SWCH_ON function + //printf("TC_SW_OFF_RTC\r\n"); // call PWR_SWCH_ON function //tm_pointer = new Short_tm; tm_pointer->TM_string[0] = 0xB0; tm_pointer->TM_string[1] = GETpacket_seq_count(tc_ptr); @@ -799,7 +781,7 @@ } else if(GETpid(tc_ptr)==0x23) { - //gPC.printf("TC_SW_OFF_BAE\r\n"); // call PWR_SWCH_ON function + //printf("TC_SW_OFF_BAE\r\n"); // call PWR_SWCH_ON function //tm_pointer = new Short_tm; tm_pointer->TM_string[0] = 0xB0; tm_pointer->TM_string[1] = GETpacket_seq_count(tc_ptr); @@ -816,7 +798,7 @@ } else if(GETpid(tc_ptr)==0x24) { - //gPC.printf("TC_SW_OFF_PL_DL\r\n"); // call PWR_SWCH_ON function + //printf("TC_SW_OFF_PL_DL\r\n"); // call PWR_SWCH_ON function //tm_pointer = new Short_tm; tm_pointer->TM_string[0] = 0xB0; tm_pointer->TM_string[1] = GETpacket_seq_count(tc_ptr); @@ -833,7 +815,7 @@ } else if(GETpid(tc_ptr)==0x25) { - //gPC.printf("TC_SW_OFF_PL_AG_HV\r\n"); // call PWR_SWCH_ON function + //printf("TC_SW_OFF_PL_AG_HV\r\n"); // call PWR_SWCH_ON function //tm_pointer = new Short_tm; tm_pointer->TM_string[0] = 0xB0; tm_pointer->TM_string[1] = GETpacket_seq_count(tc_ptr); @@ -850,7 +832,7 @@ } else if(GETpid(tc_ptr)==0x26) { - //gPC.printf("TC_SW_OFF_V_A_EN\r\n"); // call PWR_SWCH_ON function + //printf("TC_SW_OFF_V_A_EN\r\n"); // call PWR_SWCH_ON function //tm_pointer = new Short_tm; tm_pointer->TM_string[0] = 0xB0; tm_pointer->TM_string[1] = GETpacket_seq_count(tc_ptr); @@ -867,7 +849,7 @@ } else if(GETpid(tc_ptr)==0x31) { - //gPC.printf("TC_RST_SD\r\n"); // call PWR_SWCH_ON function + //printf("TC_RST_SD\r\n"); // call PWR_SWCH_ON function //tm_pointer = new Short_tm; tm_pointer->TM_string[0] = 0xB0; tm_pointer->TM_string[1] = GETpacket_seq_count(tc_ptr); @@ -884,7 +866,7 @@ } else if(GETpid(tc_ptr)==0x32) { - //gPC.printf("TC_RST_RTC\r\n"); // call PWR_SWCH_ON function + //printf("TC_RST_RTC\r\n"); // call PWR_SWCH_ON function //tm_pointer = new Short_tm; tm_pointer->TM_string[0] = 0xB0; tm_pointer->TM_string[1] = GETpacket_seq_count(tc_ptr); @@ -901,7 +883,7 @@ } else if(GETpid(tc_ptr)==0x33) { - //gPC.printf("TC_RST_BAE\r\n"); // call PWR_SWCH_ON function + //printf("TC_RST_BAE\r\n"); // call PWR_SWCH_ON function //tm_pointer = new Short_tm; tm_pointer->TM_string[0] = 0xB0; tm_pointer->TM_string[1] = GETpacket_seq_count(tc_ptr); @@ -918,7 +900,7 @@ } else if(GETpid(tc_ptr)==0x34) { - //gPC.printf("TC_RST_PL_DL\r\n"); // call PWR_SWCH_ON function + //printf("TC_RST_PL_DL\r\n"); // call PWR_SWCH_ON function //tm_pointer = new Short_tm; tm_pointer->TM_string[0] = 0xB0; tm_pointer->TM_string[1] = GETpacket_seq_count(tc_ptr); @@ -936,7 +918,7 @@ } else if(GETpid(tc_ptr)==0xC1) { - //gPC.printf("RESET_HK_COUNTER\r\n"); // call PWR_SWCH_ON function + //printf("RESET_HK_COUNTER\r\n"); // call PWR_SWCH_ON function //tm_pointer = new Short_tm; tm_pointer->TM_string[0] = 0xB0; tm_pointer->TM_string[1] = GETpacket_seq_count(tc_ptr); @@ -953,7 +935,7 @@ } else if(GETpid(tc_ptr)==0xF1) { - //gPC.printf("RD_RTC\r\n"); //call RD_RTC + //printf("RD_RTC\r\n"); //call RD_RTC //tm_pointer = new Short_tm; tm_pointer->TM_string[0] = 0xD0; tm_pointer->TM_string[1] = GETpacket_seq_count(tc_ptr); @@ -974,7 +956,7 @@ } else { - //gPC.printf("INVALID TC\r\n"); + //printf("INVALID TC\r\n"); //tm_pointer = new Short_tm; tm_pointer->TM_string[0] = 0xB0; tm_pointer->TM_string[1] = GETpacket_seq_count(tc_ptr); @@ -996,7 +978,7 @@ } default: { - //gPC.printf("INVALID TC"); //send invalid TC TM + //printf("INVALID TC"); //send invalid TC TM //tm_pointer = new Short_tm; tm_pointer->TM_string[0] = 0xB0; tm_pointer->TM_string[1] = GETpacket_seq_count(tc_ptr); @@ -1017,10 +999,10 @@ } case 3: { - //gPC.printf("Telecommand is for PL\r\n"); - // gPC.printf("Informing PL about TC using I2C\r\n"); //interrupt to be sent to the bae + //printf("Telecommand is for PL\r\n"); + // printf("Informing PL about TC using I2C\r\n"); //interrupt to be sent to the bae // FCTN_I2C_WRITE((char*)tc_ptr->TC_string); - // //gPC.printf("sent the Telecommand to BAE\r\n"); //packet along with crc will be sent when bae is ready + // printf("sent the Telecommand to BAE\r\n"); //packet along with crc will be sent when bae is ready // wait(1); //wait time is to be optimised // if(tm_status_4m_slv == 1) // { @@ -1029,15 +1011,15 @@ // } // if(received == 1 ) // { - // //gPC.printf("Telemetry is received from BAE\r\n"); - // //gPC.printf("%s", tm_ptr->TM_string); + // printf("Telemetry is received from BAE\r\n"); + // printf("%s", tm_ptr->TM_string); // received = 0; // } // similar to BAE functions break; } default: //invalid TC { - //gPC.printf("INVALID TC\r\n"); + //printf("INVALID TC\r\n"); //tm_pointer = new Short_tm; tm_pointer->TM_string[0] = 0xB0; tm_pointer->TM_string[1] = GETpacket_seq_count(tc_ptr); @@ -1195,22 +1177,6 @@ #define EXECUTE_OBOSC_ONLY {\ int reset_flag = 0;\ - 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{\ - /*PENDING: RESET CDMS*/\ - break;\ - }\ - }\ - uint8_t obosc_executed_count = 0;\ 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;\ @@ -1228,22 +1194,60 @@ /*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_current->next_TM, reset_flag);\ - ++obosc_executed_count;\ - /*INCREMENT POINTER TO THE LAST NODE*/\ - int overflowCountOBinside = 0;\ + Base_tm *obosc_tm_head = NULL;\ + get_call_sign(obosc_tm_head);\ + Base_tm *obosc_tm_core = NULL;\ + execute_obosc_core(current_TC, obosc_tm_core, reset_flag);\ + uint16_t temp16 = TC_STATE_SUCCESSFULLY_EXECUTED;\ + PUTexec_status(current_TC, temp16);\ + 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( overflowCountOBinside < TM_OVERFLOW_CONSTANT ){\ + if( overflowCountOBONLY < TM_OVERFLOW_CONSTANT ){\ obosc_tm_current = obosc_tm_current->next_TM;\ - ++overflowCountOBinside;\ + ++overflowCountOBONLY;\ }\ else{\ /*PENDING: RESET CDMS*/\ break;\ }\ }\ - uint16_t temp16 = TC_STATE_SUCCESSFULLY_EXECUTED;\ - PUTexec_status(current_TC, temp16);\ + obosc_tm_current->next_TM = obosc_tm_core;\ + obosc_tm_current = obosc_tm_head;\ + while( obosc_tm_current != NULL ){\ + int length = TM_SHORT_SIZE;\ + if( GETshort_or_long_tm(obosc_tm_current->fields) == 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;\ + }\ + /*snd_tm.head_pointer(obosc_tm_head);*/\ + /*adf_not_SDcard();*/\ + /*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{\ + /*PENDING: RESET CDMS: MEMORY LEAK FOUND*/\ + break;\ + }\ + }\ + if ( reset_flag ==1 ){\ + reset_all;\ + }\ }\ }\ }\ @@ -1256,15 +1260,6 @@ }\ }\ }\ - if( obosc_executed_count != 0 ){\ - snd_tm.head_pointer(obosc_tm_head);\ - adf_not_SDcard;\ - }\ - delete_all_tm(obosc_tm_head);\ - if ( reset_flag == 1 ){\ - reset_all;\ - break;\ - }\ } #define EXECUTE_TC {\ @@ -1282,17 +1277,6 @@ 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) ){\ - gMASTER_STATE = TCL_STATE_COMPLETED;\ - 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);\ - /*Send only call sign, ACK_L1*/\ - snd_tm.head_pointer(tm_ptr_head);\ - adf_not_SDcard;\ - delete_all_tm(tm_ptr_head);\ - }\ break;\ }\ else if( (current_exec_status == TC_STATE_EXECUTION_FAILED) && (GETabort_on_nack(current_TC) == 1) ){\ @@ -1302,10 +1286,38 @@ get_call_sign(tm_ptr_head);\ Base_tm *tm_ptr = tm_ptr_head;\ get_ack_l1(tm_ptr->next_TM);\ - /*Send only call sign, ACK_L1*/\ - snd_tm.head_pointer(tm_ptr_head);\ - adf_not_SDcard;\ - delete_all_tm(tm_ptr_head);\ + tm_ptr = tm_ptr_head;\ + while( tm_ptr != NULL ){\ + int length = TM_SHORT_SIZE;\ + if( GETshort_or_long_tm(tm_ptr->fields) == 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;\ + }\ + /*snd_tm.head_pointer(tm_ptr_head);*/\ + /*adf_not_SDcard;*/\ + /*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{\ + /*PENDING: RESET CDMS*/\ + break;\ + }\ + }\ break;\ }\ else if( (current_exec_status == TC_STATE_UNEXECUTED) || (current_exec_status == TC_STATE_MARKED_RETRY) ){\ @@ -1325,9 +1337,6 @@ /*gPC.printf("obosc tc inside normal tc at %u\r\n", execute_psc);*/\ /*EXECUTION OF OBOSC TC*/\ /*SKIP EXECUTION OF OBOSC HERE*/\ - if( execute_psc == (gTOTAL_VALID_TC-1) ){\ - gMASTER_STATE = TCL_STATE_COMPLETED;\ - }\ break;\ }\ else{\ @@ -1357,6 +1366,25 @@ /*LAST TC IS EXECUTED*/\ 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->fields) == SHORT_TM_CODE ){\ @@ -1392,10 +1420,39 @@ if( tempPAhot == 0x00 ){\ gFLAGS = gFLAGS | COM_PA_HOT_FLAG;\ }\ - /*Send call sign, ACK_L1, NON OBSRS TM*/\ + tm_ptr = tm_ptr_head;\ + while( tm_ptr != NULL ){\ + int length = TM_SHORT_SIZE;\ + if( GETshort_or_long_tm(tm_ptr->fields) == 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 DATA TO GS*/\ snd_tm.head_pointer(tm_ptr_head);\ adf_not_SDcard;\ - delete_all_tm(tm_ptr_head);\ + /*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{\ + /*PENDING: RESET CDMS*/\ + break;\ + }\ + }\ }\ else{\ /*gPC.printf("sd card at %u\r\n", execute_psc);*/\ @@ -1407,13 +1464,47 @@ /*read_TC(current_TC);*/\ uint8_t tempExec = TC_STATE_SUCCESSFULLY_EXECUTED;\ PUTexec_status(current_TC, tempExec);\ - /*PENDING: ABORT ON NACK CHECK, gMASTER_STATE VERIFICATION WITH SD CARD,PA hot and session timeout, last executed ack l234*/\ + /*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->fields) == 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);\ @@ -1435,10 +1526,39 @@ if( tempPAhot == 0x00 ){\ gFLAGS = gFLAGS | COM_PA_HOT_FLAG;\ }\ - /*Send only call sign, ACK_L1, OBSRS TM*/\ - snd_tm.head_pointer(tm_ptr_head);\ - adf_not_SDcard;\ - delete_all_tm(tm_ptr_head);\ + tm_ptr = tm_ptr_head;\ + while( tm_ptr != NULL ){\ + int length = TM_SHORT_SIZE;\ + if( GETshort_or_long_tm(tm_ptr->fields) == 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 DATA TO GS*/\ + /*snd_tm.head_pointer(tm_ptr_head);*/\ + /*adf_SDcard();*/\ + /*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{\ + /*PENDING: RESET CDMS*/\ + break;\ + }\ + }\ }\ }\ break;\