pl ack in tmtc

Dependencies:   FreescaleIAP SimpleDMA mbed-rtos mbed

Fork of COM_MNG_TMTC_SIMPLE_pl123 by shubham c

Revision:
15:1c1ca992b43b
Parent:
14:08c2c887ea09
Child:
16:538de1b20b3a
Child:
18:f87a5b919d60
--- a/COM_MNG_TMTC.h	Thu Dec 31 12:04:21 2015 +0000
+++ b/COM_MNG_TMTC.h	Thu Dec 31 13:14:59 2015 +0000
@@ -136,7 +136,7 @@
 #define continueToExecute(returnHere) {\
     uint8_t tempReturn = 0x00;\
     /*search for missing psc*/\
-    for(uint8_t p = PSC_START_VALUE ; p < (gTOTAL_VALID_TC + PSC_START_VALUE) ; ++p){\
+    for(uint8_t p = 0x00 ; p < (gTOTAL_VALID_TC) ; ++p){\
         bool flag = false;\
         Base_tc *node_ptr = gHEAD_NODE_TCL;\
         while(node_ptr != NULL){\
@@ -186,7 +186,7 @@
 #define GScodeVerification(returnHere){\
     Base_tc *testTC = gHEAD_NODE_TCL;\
     uint16_t overflowCount = 0;\
-    returnHere = 0;\
+    returnHere = 0xFF;\
     while( (overflowCount < TCL_OVERFLOW_CONSTANT) && (testTC != NULL) ){\
         if( (GETpacket_seq_count(testTC) == PSC_CALLSIGN) && (GETapid(testTC) == APID_CALLSIGN) ){\
             uint8_t temp8 = testTC->TC_string[1];\
@@ -554,7 +554,7 @@
             break;\
         }\
     }\
-    for(uint8_t execute_psc = PSC_START_VALUE ; execute_psc < (gTOTAL_VALID_TC+PSC_START_VALUE) ; ++execute_psc){\
+    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;\
         while( current_TC != NULL ){\
@@ -598,6 +598,20 @@
             }\
         }\
     }\
+    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*/\
@@ -619,7 +633,7 @@
 
 #define EXECUTE_TC {\
     gMASTER_STATE = TCL_STATE_EXECUTING;\
-    for(uint8_t execute_psc = PSC_START_VALUE ; execute_psc < (PSC_START_VALUE+gTOTAL_VALID_TC) ; ++execute_psc ){\
+    for(uint8_t execute_psc = PSC_START_VALUE ; execute_psc < PSC_START_VALUE ; ++execute_psc ){\
         /*gLEDG = !gLEDG;*/\
         /*gLEDR = !gLEDR;*/\
         Base_tc* current_TC = gHEAD_NODE_TCL;\
@@ -676,7 +690,7 @@
                             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) ){\
+                            else if( execute_psc == (gTOTAL_VALID_TC-1) ){\
                                 /*LAST TC IS EXECUTED*/\
                                 gMASTER_STATE = TCL_STATE_COMPLETED;\
                             }\
@@ -715,6 +729,20 @@
                             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;\
+                                }\
+                                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();*/\
@@ -750,7 +778,7 @@
                             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) ){\
+                            else if( execute_psc == (gTOTAL_VALID_TC-1) ){\
                                 gMASTER_STATE = TCL_STATE_COMPLETED;\
                             }\
                         }\