Simple version of COM_MNG_TMTC_CODE for IITMSAT.

Dependencies:   mbed-rtos mbed FreescaleIAP SimpleDMA

Revision:
154:9aec89c8cdc7
Parent:
149:827e23febfdf
Child:
168:087d16523507
--- a/OBSRS.h	Wed Apr 06 13:11:15 2016 +0000
+++ b/OBSRS.h	Mon Apr 11 16:04:55 2016 +0000
@@ -500,6 +500,16 @@
             if(create_Ack_andcallsign){
 /*                gPC.printf("cr ack\r\n");*/
                 enable_SCH = true;
+                uint8_t temp2 = TC_STATE_SUCCESSFULLY_EXECUTED; // see all the possible cases
+                PUTexec_status(current_obsrs_tc, temp2);
+                if( (GETexec_status(current_obsrs_tc) == TC_STATE_EXECUTION_FAILED) && (GETabort_on_nack(current_obsrs_tc) == 1) ){
+                                gMASTER_STATE = TCL_STATE_ABORTED;
+                }
+                else if( GETpacket_seq_count(current_obsrs_tc) == (gTOTAL_VALID_TC-1) ){
+                    gMASTER_STATE = TCL_STATE_COMPLETED;
+                }
+                
+                
                 create_Ack_andcallsign = false;
                 Base_tm *ack_and_callsign = NULL;
                 Base_tm *ack_head = NULL;
@@ -515,14 +525,9 @@
                 T_frame_in_Ackandcallsign = 2*snd_tm.make_shor_tm();
 /*                gPC.printf(" T_frame_in_Ackandcallsign = %d\r\n",T_frame_in_Ackandcallsign);*/
                 Base_tm *ack_l234 = ack_and_callsign->next_TM;
-                uint8_t temp2 = TC_STATE_SUCCESSFULLY_EXECUTED; // see all the possible cases
-                PUTexec_status(current_obsrs_tc, temp2);
-                if( (GETexec_status(current_obsrs_tc) == TC_STATE_EXECUTION_FAILED) && (GETabort_on_nack(current_obsrs_tc) == 1) ){
-                                gMASTER_STATE = TCL_STATE_ABORTED;
-                }
-                else if( GETpacket_seq_count(current_obsrs_tc) == (gTOTAL_VALID_TC-1) ){
-                    gMASTER_STATE = TCL_STATE_COMPLETED;
-                }
+                
+                ack_and_callsign = ack_head->next_TM;
+                
                 if( GETshort_or_long_tm(ack_l234) == SHORT_TM_CODE ){
                     for(int i = 0 ; i < TM_SHORT_SIZE ; ++i){
                         gLAST_TM[i] = ack_l234->TM_string[i];
@@ -535,7 +540,6 @@
                         gLAST_TM_SHORT_OR_LONG = LONG_TM_CODE;
                     }
                 }
-                ack_and_callsign = ack_head->next_TM;
                 
 /*                gPC.printf("ex cr ack\r\n");*/
             }    
@@ -592,11 +596,13 @@
                    enable_T_frame = true;
                    enable_SCH = true;
                 }
-                else if(ack_code == 0x85){
+                else if(read_success == 1){
+                    ack_code = 0x85;
                     gPC.printf("Hardware failure");
                     enable_T_frame = false;
                 }
-                else if(ack_code == 0x86){
+                else if(read_success == 2){
+                    ack_code = 0x86;
                     gPC.printf("Invalid FSC");
                     enable_T_frame = false;
                 }