CDMS code for testing sbc
Dependencies: FreescaleIAP SimpleDMA mbed-rtos mbed
Fork of CDMS_CODE by
Diff: COM_MNG_TMTC.h
- Revision:
- 58:5c59f28620bc
- Parent:
- 56:a88e16f6c18e
- Child:
- 69:20f09a0c3fd2
- Child:
- 71:9193fbdaa3e1
diff -r a88e16f6c18e -r 5c59f28620bc COM_MNG_TMTC.h --- a/COM_MNG_TMTC.h Thu Jan 14 15:33:57 2016 +0000 +++ b/COM_MNG_TMTC.h Fri Jan 15 12:02:12 2016 +0000 @@ -36,6 +36,42 @@ delete tc_ptr;\ } +#define print_all_tm(tm_ptr_head){\ + Base_tm *temp_tm_ptr = tm_ptr_head;\ + while( temp_tm_ptr != NULL ){\ + int length = TM_SHORT_SIZE;\ + if( GETshort_or_long_tm(temp_tm_ptr->fields) == SHORT_TM_CODE ){\ + length = TM_SHORT_SIZE;\ + }\ + else{\ + length = TM_LONG_SIZE;\ + }\ + for(int i = 0 ; i < length ; ++i){\ + gPC.putc(temp_tm_ptr->TM_string[i]);\ + }\ + temp_tm_ptr = temp_tm_ptr->next_TM;\ + }\ + /*snd_tm.head_pointer(tm_ptr_head);*/\ +} + +#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 @@ -1177,6 +1213,22 @@ #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;\ @@ -1194,57 +1246,22 @@ /*gPC.printf("It is obosc: %u\r\n", execute_psc);*/\ /*EXECUTION OF OBOSC TC*/\ /*WARNING: LARGE MEMORY UTILIZATION FOR TC-LIST-REPORT */\ - 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;\ + execute_obosc_core(current_TC, obosc_tm_current->next_TM, reset_flag);\ + ++obosc_executed_count;\ + /*INCREMENT POINTER TO THE LAST NODE*/\ + int overflowCountOBinside = 0;\ while( obosc_tm_current->next_TM != NULL ){\ - if( overflowCountOBONLY < TM_OVERFLOW_CONSTANT ){\ + if( overflowCountOBinside < TM_OVERFLOW_CONSTANT ){\ obosc_tm_current = obosc_tm_current->next_TM;\ - ++overflowCountOBONLY;\ + ++overflowCountOBinside;\ }\ else{\ /*PENDING: RESET CDMS*/\ break;\ }\ }\ - 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;\ - }\ - }\ + uint16_t temp16 = TC_STATE_SUCCESSFULLY_EXECUTED;\ + PUTexec_status(current_TC, temp16);\ }\ }\ }\ @@ -1256,11 +1273,16 @@ break;\ }\ }\ - if ( reset_flag ==1 ){\ - reset_all;\ - break;\ - }\ + }\ + if( obosc_executed_count != 0 ){\ + print_all_tm(obosc_tm_head);\ + /*adf_not_SDcard();*/\ }\ + delete_all_tm(obosc_tm_head);\ + if ( reset_flag == 1 ){\ + reset_all;\ + break;\ + }\ } #define EXECUTE_TC {\ @@ -1278,6 +1300,15 @@ 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);\ + print_all_tm(tm_ptr_head);\ + delete_all_tm(tm_ptr_head);\ + }\ break;\ }\ else if( (current_exec_status == TC_STATE_EXECUTION_FAILED) && (GETabort_on_nack(current_TC) == 1) ){\ @@ -1287,37 +1318,8 @@ 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->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);*/\ - /*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;\ - }\ - }\ + print_all_tm(tm_ptr_head);\ + delete_all_tm(tm_ptr_head);\ break;\ }\ else if( (current_exec_status == TC_STATE_UNEXECUTED) || (current_exec_status == TC_STATE_MARKED_RETRY) ){\ @@ -1404,39 +1406,9 @@ 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->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);\ + print_all_tm(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;\ - }\ - }\ + delete_all_tm(tm_ptr_head);\ }\ else{\ /*gPC.printf("sd card at %u\r\n", execute_psc);*/\ @@ -1448,28 +1420,13 @@ /*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, session timeout, last executed ack l234*/\ + /*PENDING: ABORT ON NACK CHECK, gMASTER_STATE VERIFICATION WITH SD CARD,PA hot and 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;\ }\ - /*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);\ @@ -1491,39 +1448,8 @@ 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->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;\ - }\ - }\ + print_all_tm(tm_ptr_head);\ + delete_all_tm(tm_ptr_head);\ }\ }\ break;\