publishing to check changes in cdms code

Dependencies:   FreescaleIAP SimpleDMA mbed-rtos mbed

Fork of CDMS_CODE_samp_23SEP_DMA_flag by samp Srinivasan

Revision:
180:ccc21cc163f8
Parent:
169:451b54864992
Child:
187:2c7263530c57
Child:
211:77bee0cbebfe
diff -r 67588115bca3 -r ccc21cc163f8 COM_MNG_TMTC.h
--- a/COM_MNG_TMTC.h	Fri Apr 22 19:43:13 2016 +0000
+++ b/COM_MNG_TMTC.h	Wed May 25 15:28:32 2016 +0000
@@ -152,7 +152,7 @@
         }\
     }\
     else{\
-        if( (gMASTER_STATE == TCL_STATE_INCOMPLETE) || (gMASTER_STATE == TCL_STATE_COMPLETED) ){\
+        if( (gMASTER_STATE == TCL_STATE_INCOMPLETE) || (gMASTER_STATE == TCL_STATE_COMPLETED) || (gMASTER_STATE == TCL_STATE_ABORTED) ){\
             gMASTER_STATE = TCL_STATE_INCOMPLETE;\
         }\
     }\
@@ -945,6 +945,8 @@
     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;\
@@ -963,27 +965,13 @@
                                 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);\
+                            Base_tm *obosc_tm_current = obosc_tm_core;\
+                            while(obosc_tm_core != NULL){\
+                               obosc_tm_core = obosc_tm_core->next_TM;\
+                            }\
                             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( overflowCountOBONLY < TM_OVERFLOW_CONSTANT ){\
-                                    obosc_tm_current = obosc_tm_current->next_TM;\
-                                    ++overflowCountOBONLY;\
-                                }\
-                                else{\
-                                    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) == SHORT_TM_CODE ){\
@@ -997,24 +985,6 @@
                                 }\
                                 obosc_tm_current = obosc_tm_current->next_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;\
                             }\
@@ -1030,6 +1000,42 @@
             }\
         }\
     }\
+    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;\
+            }\
+        }\
+    }\    
 }
 
 #define EXECUTE_TC {\
@@ -1050,6 +1056,10 @@
                     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) ){\
@@ -1141,25 +1151,6 @@
                                 /*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) == SHORT_TM_CODE ){\
@@ -1360,7 +1351,7 @@
             if (DEBUG)\
                 gPC.puts("ABORTING DUE TO ABORT ON NACK\r\n");\
             /*EXITED DUE TO ABORT ON NACK:*/\
-            /*PENDING : POWER OFF COM TX*/\
+            /*COM_TX_CNTRL = 0;*/\
             RX1M.attach(&rx_read, Serial::RxIrq);\
             gFLAGS = gFLAGS & (~COM_MNG_TMTC_RUNNING_FLAG);\
             break;\
@@ -1368,7 +1359,7 @@
         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*/\
+            /*COM_TX_CNTRL = 0;*/\
             RX1M.attach(&rx_read, Serial::RxIrq);\
             gFLAGS = gFLAGS & (~COM_MNG_TMTC_RUNNING_FLAG);\
             break;\