lkdsnf;

Dependencies:   FreescaleIAP SimpleDMA mbed-rtos mbed

Fork of COM_MNG_TMTC_SIMPLE_PL_Working by Siva ram

Revision:
74:65a271b5cf17
Parent:
73:6c99294b7802
--- a/COM_MNG_TMTC.h	Mon Jan 18 22:21:23 2016 +0000
+++ b/COM_MNG_TMTC.h	Mon Jan 18 22:49:35 2016 +0000
@@ -36,6 +36,24 @@
     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
@@ -1177,6 +1195,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,60 +1228,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;\
-                                }\
-                            }\
-                            if ( reset_flag ==1 ){\
-                                reset_all;\
-                            }\
+                            uint16_t temp16 = TC_STATE_SUCCESSFULLY_EXECUTED;\
+                            PUTexec_status(current_TC, temp16);\
                         }\
                     }\
                 }\
@@ -1260,6 +1256,15 @@
             }\
         }\
     }\
+    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 {\