publishing to check changes in cdms code
Dependencies: FreescaleIAP SimpleDMA mbed-rtos mbed
Fork of CDMS_CODE_samp_23SEP_DMA_flag by
Diff: COM_MNG_TMTC.h
- Revision:
- 4:104dd82c99b8
- Parent:
- 2:2caf2a9a13aa
- Child:
- 5:ab276a17ca07
diff -r 6c81fc8834e2 -r 104dd82c99b8 COM_MNG_TMTC.h --- a/COM_MNG_TMTC.h Wed Dec 23 05:37:55 2015 +0000 +++ b/COM_MNG_TMTC.h Tue Dec 29 06:50:19 2015 +0000 @@ -19,34 +19,64 @@ #define fill_l1_ack(tm_ptr) {\ uint8_t temp8;\ tm_ptr->next_TM = NULL;\ - temp8 = 0xA;\ + temp8 = TMID_ACK_L1;\ PUTtmid(tm_ptr->fields, temp8);\ - temp8 = 0x00;\ + temp8 = SHORT_TM_CODE;\ PUTshort_or_long_tm(tm_ptr->fields, temp8);\ 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;\ - tm_ptr->TM_string[3] = (gMASTER_STATE << 4) & 0xF0;\ } -#define put_crc_l1_ack(tm_ptr, num_crc) {\ - tm_ptr->TM_string[2] = num_crc & 0xFF;\ - crc_checksum = crc16_gen(tm_ptr->TM_string, TM_SHORT_SIZE-2);\ +#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 << 5) & 0xE0;\ + /*PA HOT*/\ + if( gFLAGS & COM_PA_HOT_FLAG ){\ + tm_ptr->TM_string[3] |= (1 << 4);\ + }\ + else{\ + tm_ptr->TM_string[3] &= ~(1 << 4);\ + }\ + uint16_t crc_checksum = crc16_gen(tm_ptr->TM_string, TM_SHORT_SIZE-2);\ tm_ptr->TM_string[TM_SHORT_SIZE-2] = (crc_checksum >> 8) & 0xFF;\ tm_ptr->TM_string[TM_SHORT_SIZE-1] = crc_checksum & 0xFF;\ } -#define detect_ack(tm_ptr, temp_ack) {\ - uint8_t temp8;\ - if( tm_ptr != NULL ){\ - temp8 = tm_ptr->TM_string[3];\ - if((temp8 == 0xE0) || (temp8 == 0xA0) || (temp8 == 0xC0))\ - temp_ack = 0x01;\ +#define detect_ack(tm_ptr, temp_ack, tc_psc) {\ + 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;\ + }\ + 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] ) ){\ + if( tm_ptr != NULL ){\ + 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 = 0x00;\ + /*CHECK FOR NACK CODE: CRC FAIL NACK*/\ + temp8 = tm_ptr->TM_string[TM_ACK_CODE_INDEX];\ + temp8 = temp8 & 0x0F;\ + if( temp8 == 0x1 ){\ + tm_ptr->TM_string[2] = tc_psc;\ + }\ + }\ + }\ else\ temp_ack = 0x00;\ }\ - else\ + else{\ temp_ack = 0x00;\ + }\ } #define isit_obosc(tc_ptr, temp_obosc) {\ @@ -167,81 +197,188 @@ @param: none @return: none */ -#define send_l1_ack {\ +/*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 get_ack_l1( tm_ptr ){\ Base_tc *current_TC = gHEAD_NODE_TCL;\ Base_tm *l1_ack = new Short_tm;\ - Base_tm *l1_ack_head = l1_ack;\ + /*APPEND TO THE tm_ptr HERE*/\ + tm_ptr = l1_ack;\ fill_l1_ack(l1_ack);\ int TC_count = 0;\ - uint16_t crc_checksum = 0;\ + int overflowCountL1 = 0;\ while(current_TC != NULL){\ - /*IF CRC PASS*/\ - if( (GETcrc_pass(current_TC) == 1) ){\ - if(TC_count > 4){\ - /*extend the TM linked list*/\ - TC_count = 0;\ - l1_ack->next_TM = new Short_tm;\ - l1_ack = l1_ack->next_TM;\ - fill_l1_ack(l1_ack);\ - /*PENDING: FILL TC_EXEC_CODE, APPEND CRC TO THE TM*/\ - put_crc_l1_ack( l1_ack, gTOTAL_CRC_FAIL_TC );\ + if( overflowCountL1 < TCL_OVERFLOW_CONSTANT ){\ + /*IF CRC PASS*/\ + if( (GETcrc_pass(current_TC) == 1) ){\ + if(TC_count > 4){\ + /*extend the TM linked list*/\ + TC_count = 0;\ + l1_ack->next_TM = new Short_tm;\ + l1_ack = l1_ack->next_TM;\ + fill_l1_ack(l1_ack);\ + /*PENDING: FILL TC_EXEC_CODE, APPEND CRC TO THE TM*/\ + put_crc_l1_ack( l1_ack );\ + }\ + /*PSC starts from 7th byte*/\ + l1_ack->TM_string[6+TC_count] = GETpacket_seq_count(current_TC);\ + /*TC exec status*/\ + switch(TC_count){\ + case 0:\ + l1_ack->TM_string[3] = (GETexec_status(current_TC)) & 0x0F;\ + break;\ + case 1:\ + l1_ack->TM_string[4] = (GETexec_status(current_TC) << 4) & 0xF0;\ + break;\ + case 2:\ + l1_ack->TM_string[4] |= (GETexec_status(current_TC)) & 0x0F;\ + break;\ + case 3:\ + l1_ack->TM_string[5] = (GETexec_status(current_TC) << 4) & 0xF0;\ + break;\ + case 4:\ + l1_ack->TM_string[5] |= (GETexec_status(current_TC)) & 0x0F;\ + }\ + ++TC_count;\ }\ - /*PSC starts from 7th byte*/\ - l1_ack->TM_string[6+TC_count] = current_TC->TC_string[0];\ - /*TC exec status*/\ + current_TC = current_TC->next_TC;\ + ++overflowCountL1;\ + }\ + else{\ + /*PENDING: RESET CDMS*/\ + break;\ + }\ + }\ + /*FILL UP THE REMAINING FIELDS WITH 0x00 as PSC, AND 0xF as tc exec status*/\ + if( (TC_count < 5) && (TC_count != 0) ){\ + while(TC_count < 5){\ + l1_ack->TM_string[6+TC_count] = 0x00;\ switch(TC_count){\ - case 0:\ - l1_ack->TM_string[3] |= (GETexec_status(current_TC)) & 0x0F;\ - break;\ case 1:\ - l1_ack->TM_string[4] = (GETexec_status(current_TC) << 4) & 0xF0;\ + l1_ack->TM_string[4] = 0xF0;\ break;\ case 2:\ - l1_ack->TM_string[4] |= (GETexec_status(current_TC)) & 0x0F;\ + l1_ack->TM_string[4] |= 0x0F;\ break;\ case 3:\ - l1_ack->TM_string[5] = (GETexec_status(current_TC) << 4) & 0xF0;\ + l1_ack->TM_string[5] = 0xF0;\ break;\ case 4:\ - l1_ack->TM_string[5] |= (GETexec_status(current_TC)) & 0x0F;\ + l1_ack->TM_string[5] |= 0x0F;\ }\ ++TC_count;\ }\ - current_TC = current_TC->next_TC;\ + put_crc_l1_ack(l1_ack);\ }\ - /*FILL UP THE REMAINING FIELDS WITH 0x01: 0x00 => problem with GS*/\ - if(TC_count < 5){\ - while(TC_count < 5){\ - l1_ack->TM_string[6+TC_count] = current_TC->TC_string[0];\ - switch(TC_count){\ - case 0:\ - l1_ack->TM_string[3] |= (GETexec_status(current_TC)) & 0x0F;\ - break;\ - case 1:\ - l1_ack->TM_string[4] = (GETexec_status(current_TC) << 4) & 0xF0;\ - break;\ - case 2:\ - l1_ack->TM_string[4] |= (GETexec_status(current_TC)) & 0x0F;\ +} + +/*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 get_tc_list(tm_ptr, thePSC){\ + uint8_t TM_PSC = 0x00;\ + uint8_t TC_PSC = thePSC;\ + int overflowCount = 0;\ + uint8_t TC_LIST_TAG = 0x00;\ + Base_tc *temp_tc = gHEAD_NODE_TCL;\ + bool first_time = true;\ + Base_tm *theHeadTM = NULL;\ + while( temp_tc != NULL ){\ + if( overflowCount < TCL_OVERFLOW_CONSTANT ){\ + TM_PSC = TM_PSC + 1;\ + /*Increment TM_PSC for every new TM pointer created*/\ + Base_tm *temp_tm = new Long_tm;\ + temp_tm->next_TM = NULL;\ + if( first_time ){\ + first_time = false;\ + tm_ptr = temp_tm;\ + theHeadTM = temp_tm;\ + }\ + uint8_t temp8 = LONG_TM_CODE;\ + PUTshort_or_long_tm(temp_tm->fields, temp8);\ + temp8 = TMID_TCL;\ + PUTtmid((temp_tm->fields), temp8);\ + temp_tm->TM_string[0] = 0x38;\ + /*Frame type(1) = 0; TMID = 0111; Spare = 000*/\ + temp_tm->TM_string[1] = TC_PSC;\ + temp_tm->TM_string[3] = TM_PSC;\ + int index = 4, num_of_short_tc = 0;\ + while(temp_tc != NULL){\ + if( overflowCount < TCL_OVERFLOW_CONSTANT ){\ + if( GETshort_or_long_tc(temp_tc) == SHORT_TC_CODE ){\ + for( int i = 0 ; i < TC_SHORT_SIZE ; ++i ){\ + temp_tm->TM_string[index + i] = temp_tc->TC_string[i];\ + }\ + index = index + TC_SHORT_SIZE;\ + ++overflowCount;\ + /*INCREMENT STUFF*/\ + temp_tc = temp_tc->next_TC;\ + num_of_short_tc = num_of_short_tc + 1;\ + if (temp_tc == NULL){\ + for (int i = index ; i < TM_LONG_SIZE-2 ; ++i){\ + temp_tm->TM_string[i] = 0;\ + /*Fill remaining values with 0*/\ + }\ + TC_LIST_TAG = num_of_short_tc;\ + break;\ + }\ + if( (GETshort_or_long_tc(temp_tc) == LONG_TC_CODE) || (num_of_short_tc == OBOSC_TCL_MAX_SHORT_SIZE) ){\ + /*Next TC is long or memory is filled*/\ + for(int i = index; i < TM_LONG_SIZE-2 ; ++i){\ + temp_tm->TM_string[i] = 0;\ + /*Fill remaining values with 0*/\ + }\ + TC_LIST_TAG = num_of_short_tc;\ + break;\ + }\ + }\ + else if (TC_LIST_TAG == OBOSC_TCL_TAG_LONG_FIRST_HALF){\ + /*Long TC, 2nd half*/\ + for (int i = 0; i < OBOSC_LONG_TC_SECOND_HALF_SIZE ; ++i){\ + temp_tm->TM_string[index + i] = temp_tc->TC_string[OBOSC_LONG_TC_FIRST_HALF_SIZE + i];\ + /*Fill the TM with TC_values*/\ + }\ + for (int i = OBOSC_LONG_TC_SECOND_HALF_SIZE + index ; i < TM_LONG_SIZE-2 ; ++i ){\ + temp_tm->TM_string[i] = 0;\ + /*Fill remaining values with 0*/\ + }\ + temp_tc = temp_tc->next_TC;\ + TC_LIST_TAG = OBOSC_TCL_TAG_LONG_SECOND_HALF;\ + ++overflowCount;\ + break;\ + }\ + else{\ + /*Long TC, 1st half */\ + for (int i = 0; i < OBOSC_LONG_TC_FIRST_HALF_SIZE; ++i){\ + temp_tm->TM_string[index + i] = temp_tc->TC_string[i];\ + /*Fill the TM with TC_values*/\ + }\ + for (int i = OBOSC_LONG_TC_FIRST_HALF_SIZE + index ; i < TM_LONG_SIZE-2 ; ++i ){\ + temp_tm->TM_string[i] = 0; \ + /*Fill remaining values with 0*/\ + }\ + TC_LIST_TAG = OBOSC_TCL_TAG_LONG_FIRST_HALF;\ + break;\ + }\ + }\ + else{\ + /*PENDING: reset cdms*/\ break;\ - case 3:\ - l1_ack->TM_string[5] = (GETexec_status(current_TC) << 4) & 0xF0;\ - break;\ - case 4:\ - l1_ack->TM_string[5] |= (GETexec_status(current_TC)) & 0x0F;\ + }\ }\ - ++TC_count;\ + temp_tm->TM_string[2] = TC_LIST_TAG;\ + /*TC_LIST_TAG as is updated in the inner while loop*/\ + uint16_t crc16 = crc16_gen(temp_tm->TM_string, TM_LONG_SIZE-2);\ + temp_tm->TM_string[TM_LONG_SIZE-2] = (crc16 & 0xFF00) >> 8 ;\ + temp_tm->TM_string[TM_LONG_SIZE-1] = crc16 & 0x00FF;\ + /*Attach this new node to the TM linked list*/\ + Base_tm *temp_tm_find = theHeadTM;\ + while(temp_tm_find->next_TM != NULL)\ + temp_tm_find = temp_tm_find->next_TM;\ + temp_tm_find->next_TM = temp_tm;\ + /*Attach this new node at the end*/\ }\ - put_crc_l1_ack(l1_ack, gTOTAL_CRC_FAIL_TC);\ - }\ - gPC.puts("Sending l1 ack\r\n");\ - snd_tm.head_pointer(l1_ack_head);\ - adf_not_SDcard();\ - /*delete the TM*/\ - l1_ack = l1_ack_head;\ - while(l1_ack != NULL){\ - Base_tm *temp = l1_ack->next_TM;\ - delete l1_ack;\ - l1_ack = temp;\ + else{\ + /*PENDING: reset CDMS*/\ + break;\ + }\ }\ } @@ -254,93 +391,197 @@ // EXECUTE OBOSC #define execute_obosc_core(tc_ptr, tm_ptr) {\ uint8_t service_subtype = (tc_ptr->TC_string[2]) & 0x0F;\ - /*including both lower and upper limits*/\ - uint8_t targetL = tc_ptr->TC_string[3];\ - uint8_t targetU = targetL + tc_ptr->TC_string[4] - 1;\ - if( (targetL == 0x00) && (tc_ptr->TC_string[4] == 0) ){\ - /*PENDING: ALL REPORTS BELOW*/\ - switch(service_subtype){\ - case OBOSC_SUB_REP_TCL_D:\ - break;\ - case OBOSC_SUB_REP_LE:\ - break;\ - case OBOSC_SUB_RESET:\ - break;\ - case OBOSC_SUB_REP_TCL:\ - break;\ + uint8_t temp8 = 0x00;\ + Base_tc *modify_this = gHEAD_NODE_TCL;\ + int modify_overflow = 0x00;\ + switch( service_subtype ){\ + case OBOSC_SUB_DISABLE:\ + while( modify_this != NULL ){\ + if( modify_overflow < TCL_OVERFLOW_CONSTANT ){\ + for( int i = 3 ; i < 9 ; ++i ){\ + if( tc_ptr->TC_string[i] == GETpacket_seq_count(modify_this) ){\ + uint16_t tempExec = TC_STATE_DISABLED;\ + PUTexec_status( modify_this, tempExec );\ + break;\ + }\ + }\ + modify_this = modify_this->next_TC;\ + ++modify_overflow;\ + }\ + else{\ + /*PENDING: RESET CDMS*/\ + break;\ + }\ + }\ + break;\ + case OBOSC_SUB_RETRY:\ + while( modify_this != NULL ){\ + if( modify_overflow < TCL_OVERFLOW_CONSTANT ){\ + for( int i = 3 ; i < 9 ; ++i ){\ + if( tc_ptr->TC_string[i] == GETpacket_seq_count(modify_this) ){\ + uint16_t tempExec = TC_STATE_MARKED_RETRY;\ + PUTexec_status( modify_this, tempExec );\ + break;\ + }\ + }\ + modify_this = modify_this->next_TC;\ + ++modify_overflow;\ + }\ + else{\ + /*PENDING: RESET CDMS*/\ + break;\ + }\ + }\ + break;\ + }\ + Base_tm *ackl234new = new Short_tm;\ + ackl234new->next_TM = NULL;\ + /*return telemetry pointer here*/\ + tm_ptr = ackl234new;\ + temp8 = SHORT_TM_CODE;\ + PUTshort_or_long_tm(ackl234new->fields, temp8);\ + temp8 = TMID_ACK_L234;\ + PUTtmid((ackl234new->fields), temp8);\ + 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;\ + uint8_t temp82 = TM_SHORT_SIZE;\ + PUTshort_or_long_tm(ackl234old->fields, temp82);\ + /*TMID FOR SHORT TM*/\ + uint8_t y = (gLAST_TM[0] & 0xF0) >> 4;\ + PUTtmid((ackl234old->fields), y);\ + 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;\ + uint8_t temp82 = TM_LONG_SIZE;\ + PUTshort_or_long_tm(tempLongTM->fields, temp82);\ + /*TMID FOR LONG TM*/\ + uint8_t y = (gLAST_TM[0] & 0x78) >> 3;\ + PUTtmid((tempLongTM->fields), y);\ + 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_all;\ + /*PENDING: VERIFY reset_all, RESET CDMS*/\ }\ else{\ - uint16_t temp16 = 2;\ - switch( service_subtype ){\ - case OBOSC_SUB_DISABLE:\ - temp16 = 2;\ - break;\ - case OBOSC_SUB_RETRY:\ - temp16 = 3;\ - break;\ - }\ - Base_tc *tcp = gHEAD_NODE_TCL;\ - while( tcp != NULL ){\ - uint16_t tcPSC = GETpacket_seq_count(tcp);\ - if( (tcPSC >= targetL) && (tcPSC <= targetU) ){\ - PUTexec_status(tcp, temp16);\ - }\ - tcp = tcp->next_TC;\ - }\ + /*CHANGE THE ACK CODE TO INVALID TC*/\ + ackl234new->TM_string[2] = 0xA2;\ }\ - /*PENDING: generate L234 ACK*/\ - tm_ptr = NULL;\ +} + +/*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 get_call_sign(tm_ptr) {\ + Base_tm* call_sign_tm = new Short_tm;\ + call_sign_tm->next_TM = NULL;\ + tm_ptr = call_sign_tm;\ + uint8_t temp8 = TMID_CALL_SIGN;\ + PUTtmid(call_sign_tm->fields, temp8);\ + temp8 = SHORT_TM_CODE;\ + PUTshort_or_long_tm(call_sign_tm->fields, temp8);\ + for( int i = 0 ; i < TM_SHORT_SIZE ; ++i ){\ + call_sign_tm->TM_string[i] = gCALL_SIGN_STRING[i];\ + }\ } #define EXECUTE_OBOSC_ONLY {\ - for(uint8_t execute_psc = gOBOSC_PSC ; execute_psc < (gTOTAL_VALID_TC+PSC_START_VALUE) ; ++execute_psc){\ - Base_tc* current_TC = gOBOSC_HEAD;\ + 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;\ + }\ + }\ + for(uint8_t execute_psc = PSC_START_VALUE ; execute_psc < (gTOTAL_VALID_TC+PSC_START_VALUE) ; ++execute_psc){\ + Base_tc* current_TC = gHEAD_NODE_TCL;\ + int overCount = 0;\ while( current_TC != NULL ){\ - 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) )\ - break;\ - else if( (current_exec_status == TC_STATE_EXECUTION_FAILED) && (GETabort_on_nack(current_TC) == 1) ){\ - gMASTER_STATE = TCL_STATE_ABORTED;\ - break;\ - }\ - else if( (current_exec_status == TC_STATE_UNEXECUTED) || (current_exec_status == TC_STATE_MARKED_RETRY) ){\ - Base_tm* tm_ptr = 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){\ - /*EXECUTION OF OBOSC TC*/\ - execute_obosc_core(current_TC, tm_ptr);\ - }\ - snd_tm.head_pointer(tm_ptr);\ - adf_not_SDcard();\ - uint8_t temp83 = 0x00;\ - detect_ack(tm_ptr, temp83);\ - if( temp83 == 0x01){\ - 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);\ - }\ - /*update last executed L1_ack*/\ - if( tm_ptr != NULL ){\ - for(int i = 0 ; i < TM_SHORT_SIZE ; ++i){\ - gLAST_L1_ACK[i] = gLAST_L1_ACK_BUFFER[i];\ - gLAST_L1_ACK_BUFFER[i] = tm_ptr->TM_string[i];\ + 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) ){\ + /*EXECUTION OF OBOSC TC*/\ + /*WARNING: LARGE MEMORY UTILIZATION FOR TC-LIST-REPORT */\ + execute_obosc_core(current_TC, obosc_tm_current->next_TM);\ + /*INCREMENT POINTER TO THE LAST NODE*/\ + int overflowCountOBinside = 0;\ + while( obosc_tm_current->next_TM != NULL ){\ + if( overflowCountOBinside < TM_OVERFLOW_CONSTANT ){\ + obosc_tm_current = obosc_tm_current->next_TM;\ + ++overflowCountOBinside;\ + }\ + else{\ + /*PENDING: RESET CDMS*/\ + break;\ + }\ + }\ + uint16_t temp16 = TC_STATE_SUCCESSFULLY_EXECUTED;\ + PUTexec_status(current_TC, temp16);\ }\ }\ - /*DELETE THE TM AFTER USE*/\ - while(tm_ptr != NULL){\ - Base_tm *temp = tm_ptr->next_TM;\ - delete tm_ptr;\ - tm_ptr = temp;\ - }\ }\ + current_TC = current_TC->next_TC;\ + ++overCount;\ }\ - current_TC = current_TC->next_TC;\ + else{\ + /*PENDING: REST CDMS: MEMORY LEAK FOUND*/\ + break;\ + }\ + }\ + }\ + /*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;\ + }\ + else{\ + /*PENDING: RESET CDMS: MEMORY LEAK FOUND*/\ + break;\ }\ }\ } @@ -349,105 +590,160 @@ for(uint8_t execute_psc = PSC_START_VALUE ; execute_psc < (PSC_START_VALUE+gTOTAL_VALID_TC) ; ++execute_psc ){\ /*gLEDG = !gLEDG;*/\ /*gLEDR = !gLEDR;*/\ - uint8_t tempPAhot = 0xFF;\ Base_tc* current_TC = gHEAD_NODE_TCL;\ + int overflowCount = 0;\ while(current_TC != NULL){\ - 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) )\ - break;\ - else if( (current_exec_status == TC_STATE_EXECUTION_FAILED) && (GETabort_on_nack(current_TC) == 1) ){\ - gMASTER_STATE = TCL_STATE_ABORTED;\ - 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 ){\ - /*EXECUTION OF NON SD-CARD (BOTH OBOSC and CDMS functions)*/\ - Base_tm *tm_ptr;\ - uint8_t temp82 = 0x00;\ - isit_obosc(current_TC, temp82);\ - if(temp82 == 0x01){\ - /*EXECUTION OF OBOSC TC*/\ - execute_obosc_core(current_TC, tm_ptr);\ + 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) )\ + break;\ + else if( (current_exec_status == TC_STATE_EXECUTION_FAILED) && (GETabort_on_nack(current_TC) == 1) ){\ + gMASTER_STATE = TCL_STATE_ABORTED;\ + 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 ){\ + /*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){\ + /*EXECUTION OF OBOSC TC*/\ + /*SKIP EXECUTION OF OBOSC HERE*/\ + }\ + else{\ + /*call CDMS_RLY_TMTC*/\ + /*CDMS_RLY_TMTC(current_TC, put_tm_here);*/\ + }\ + /*DETECT ACK OR NACK*/\ + uint8_t temp83 = 0x00;\ + 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{\ + 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) && (GETabort_on_nack(current_TC) == 1) ){\ + gMASTER_STATE = TCL_STATE_ABORTED;\ + }\ + else if( execute_psc == (gTOTAL_VALID_TC+PSC_START_VALUE-1) ){\ + /*LAST TC IS EXECUTED*/\ + 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);\ + int overflowCountExecute = 0;\ + while( tm_ptr->next_TM != NULL ){\ + if( overflowCountExecute < TM_OVERFLOW_CONSTANT ){\ + tm_ptr = tm_ptr->next_TM;\ + ++overflowCountExecute;\ + }\ + else{\ + /*PENDING: 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;\ + }\ + /*SEND DATA TO GS*/\ + /*snd_tm.head_pointer(tm_ptr_head);*/\ + /*adf_not_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;\ + }\ + }\ }\ else{\ - /*call CDMS_RLY_TMTC*/\ - CDMS_RLY_TMTC(current_TC, tm_ptr);\ - }\ - /*CHECK FOR HOT PA*/\ - isPAhot(tempPAhot);\ - if( tempPAhot == 0x00 ){\ - gFLAGS = gFLAGS | COM_PA_HOT_FLAG;\ - }\ - /*SEND DATA TO GS*/\ - snd_tm.head_pointer(tm_ptr);\ - adf_not_SDcard();\ - uint8_t temp83 = 0x00;\ - detect_ack(tm_ptr, temp83);\ - if( temp83 == 0x01){\ - 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);\ - }\ - /*update last executed L1_ack*/\ - if( tm_ptr != NULL ){\ - for(int i = 0 ; i < TM_SHORT_SIZE ; ++i){\ - gLAST_L1_ACK[i] = gLAST_L1_ACK_BUFFER[i];\ - gLAST_L1_ACK_BUFFER[i] = tm_ptr->TM_string[i];\ + /*EXECUTION OF SD-CARD DATA SENDING (OBSRS)*/\ + /*CHECK FOR HOT PA*/\ + uint8_t tempPAhot = 0x00;\ + isPAhot(tempPAhot);\ + if( tempPAhot == 0x00 ){\ + gFLAGS = gFLAGS | COM_PA_HOT_FLAG;\ + }\ + /*read_TC(current_TC);*/\ + /*PENDING: ABORT ON NACK CHECK WITH SD CARD*/\ + if( (GETexec_status(current_TC) == TC_STATE_EXECUTION_FAILED) && (GETabort_on_nack(current_TC) == 1) ){\ + gMASTER_STATE = TCL_STATE_ABORTED;\ }\ }\ - /*DELETE THE TM AFTER USE*/\ - while(tm_ptr != NULL){\ - Base_tm *temp = tm_ptr->next_TM;\ - delete tm_ptr;\ - tm_ptr = temp;\ - }\ }\ - else{\ - /*EXECUTION OF SD-CARD DATA SENDING (OBSRS)*/\ - /*CHECK FOR HOT PA*/\ - isPAhot(tempPAhot);\ - if( tempPAhot == 0x00 ){\ - gFLAGS = gFLAGS | COM_PA_HOT_FLAG;\ - }\ - read_TC(current_TC);\ - }\ - /*ABORT ON NACK*/\ - if( (GETexec_status(current_TC) == TC_STATE_EXECUTION_FAILED) && (GETabort_on_nack(current_TC) == 1) ){\ - gMASTER_STATE = TCL_STATE_ABORTED;\ - }\ + break;\ }\ + current_TC = current_TC->next_TC;\ + ++overflowCount;\ }\ - current_TC = current_TC->next_TC;\ - }\ - if( !(execute_psc == (PSC_START_VALUE+gTOTAL_VALID_TC-1)) ){\ - if( tempPAhot == 0 ){\ - gCOM_PA_COOLING_TIMER.attach(&after_cooling_pa, COM_PA_COOLING_TIME_LIMIT);\ - /*PENDING : POWER OFF COMM TX*/\ - RX1M.attach(&rx_read, Serial::RxIrq);\ - gFLAGS = gFLAGS & (~COM_MNG_TMTC_RUNNING_FLAG);\ + else{\ + /*PENDING: RESET CDMS*/\ break;\ }\ }\ - else if( gMASTER_STATE == TCL_STATE_ABORTED ){\ + if( gMASTER_STATE == TCL_STATE_ABORTED ){\ + /*EXITED DUE TO ABORT ON NACK:*/\ /*PENDING : POWER OFF COM TX*/\ RX1M.attach(&rx_read, Serial::RxIrq);\ gFLAGS = gFLAGS & (~COM_MNG_TMTC_RUNNING_FLAG);\ break;\ }\ - else{\ - /*PENDING : COM POWER OFF TX*/\ - reset_all;\ - /*PENDING : ENABLE THREADS*/\ - gSESSION_TIMEOUT.detach();\ - gFLAGS = gFLAGS & (~COM_SESSION_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);\ + /*PENDING : POWER OFF COMM TX*/\ + RX1M.attach(&rx_read, Serial::RxIrq);\ + gFLAGS = gFLAGS & (~COM_MNG_TMTC_RUNNING_FLAG);\ break;\ }\ }\ + /*COMPLETED EXECUTION OF TC*/\ + gMASTER_STATE = TCL_STATE_COMPLETED;\ + /*PENDING : COM POWER OFF TX*/\ + reset_all;\ + /*PENDING : ENABLE THREADS*/\ + gSESSION_TIMEOUT.detach();\ + gFLAGS = gFLAGS & (~COM_MNG_TMTC_RUNNING_FLAG);\ + gFLAGS = gFLAGS & (~COM_SESSION_FLAG);\ + break;\ } \ No newline at end of file