werwere

Dependencies:   FreescaleIAP SimpleDMA mbed-rtos mbed

Fork of COM_MNG_TMTC_SIMPLE_pl123 by Siva ram

Files at this revision

API Documentation at this revision

Comitter:
ee12b079
Date:
Wed Mar 02 17:17:45 2016 +0000
Parent:
134:4694fc291ce1
Commit message:
Testing

Changed in this revision

COM_MNG_TMTC.h Show annotated file Show diff for this revision Revisions of this file
ThreadsAndFunctions.h Show annotated file Show diff for this revision Revisions of this file
--- a/COM_MNG_TMTC.h	Tue Mar 01 17:42:30 2016 +0000
+++ b/COM_MNG_TMTC.h	Wed Mar 02 17:17:45 2016 +0000
@@ -829,6 +829,8 @@
 // CDMS TEAM CODE END
 // EXECUTE OBOSC
 #define execute_obosc_core(tc_ptr, tm_ptr, reset_flag) {\
+    if (DEBUG)\
+        gPC.puts("Inside execute_obosc_core\r\n");\
     uint8_t service_subtype = (tc_ptr->TC_string[2]) & 0x0F;\
     uint8_t temp8 = 0x00;\
     Base_tc *modify_this = gHEAD_NODE_TCL;\
@@ -932,7 +934,8 @@
         /*CHANGE THE ACK CODE TO INVALID TC*/\
         ackl234new->TM_string[2] = 0xA2;\
     }\
-    /*gPC.puts("completed obosc\r\n");*/\
+    if (DEBUG)\
+        gPC.puts("completed obosc\r\n");\
 }
 
 /*tm_ptr is the next_TM of a linked list, and should have the value NULL, i.e. tm_ptr should be the next_TM pointer of thte last node */
@@ -940,6 +943,8 @@
 
 #define EXECUTE_OBOSC_ONLY {\
     int reset_flag = 0;\
+    if (DEBUG)\
+        gPC.puts("iNSIDE EXECUTE_OBOSC_ONLY\r\n");\
     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;\
@@ -1029,6 +1034,8 @@
 
 #define EXECUTE_TC {\
     gMASTER_STATE = TCL_STATE_EXECUTING;\
+    if (DEBUG)\
+        gPC.puts("iNSIDE EXECUTE_TC\r\n");\
     /*gPC.printf("%u\r\n", gTOTAL_VALID_TC);*/\
     for(uint8_t execute_psc = PSC_START_VALUE ; execute_psc < gTOTAL_VALID_TC ; ++execute_psc ){\
         if (DEBUG)\
@@ -1092,7 +1099,8 @@
                         uint8_t temp81 = 0x00;\
                         isit_sdcard(current_TC, temp81);\
                         if( temp81 == 0x00 ){\
-                            /*gPC.printf("non sd card at %u\r\n", execute_psc);*/\
+                            if (DEBUG)\
+                                gPC.printf("non sd card at %u\r\n", execute_psc);\
                             /*EXECUTION OF NON SD-CARD (BOTH OBOSC and CDMS functions)*/\
                             Base_tm *tm_ptr_head = NULL;\
                             get_call_sign(tm_ptr_head);\
@@ -1224,7 +1232,8 @@
                             }\
                         }\
                         else{\
-                            /*gPC.printf("sd card at %u\r\n", execute_psc);*/\
+                            if (DEBUG)\
+                                gPC.printf("sd card at %u\r\n", execute_psc);\
                             /*EXECUTION OF SD-CARD DATA SENDING (OBSRS)*/\
                             Base_tm *tm_ptr_head = NULL;\
                             get_call_sign(tm_ptr_head);\
@@ -1348,7 +1357,8 @@
             break;\
         }\
         else if( gMASTER_STATE == TCL_STATE_ABORTED ){\
-            /*gPC.puts("ABORTING DUE TO ABORT ON NACK\r\n");*/\
+            if (DEBUG)\
+                gPC.puts("ABORTING DUE TO ABORT ON NACK\r\n");\
             /*EXITED DUE TO ABORT ON NACK:*/\
             /*PENDING : POWER OFF COM TX*/\
             RX1M.attach(&rx_read, Serial::RxIrq);\
@@ -1363,10 +1373,12 @@
             gFLAGS = gFLAGS & (~COM_MNG_TMTC_RUNNING_FLAG);\
             break;\
         }\
-        /*gPC.printf("successflly executed %u tc\r\n", execute_psc);*/\
+        if (DEBUG)\
+            gPC.printf("successflly executed %u tc\r\n", execute_psc);\
     }\
     if( (gMASTER_STATE == TCL_STATE_COMPLETED) || (gFLAGS & COM_SESSION_TIMEOUT_FLAG) ){\
-        /*gPC.printf("completed or session timed out: %x\r\n", gMASTER_STATE);*/\
+        if (DEBUG)\
+            gPC.printf("completed or session timed out: %x\r\n", gMASTER_STATE);\
         /*COMPLETED EXECUTION OF TC*/\
         gMASTER_STATE = TCL_STATE_COMPLETED;\
         COM_POWER_OFF_TX;\
--- a/ThreadsAndFunctions.h	Tue Mar 01 17:42:30 2016 +0000
+++ b/ThreadsAndFunctions.h	Wed Mar 02 17:17:45 2016 +0000
@@ -129,17 +129,20 @@
                     gPC.printf("valid TC rx: %u\r\n", gTOTAL_VALID_TC);
                 if( gTOTAL_VALID_TC < COM_MAX_TC_LIMIT ){
                     // CHECK WEATHER TC LIST HAS MISSING TC OR WEATHER LAST FRAME BIT IS HIGH IN THE LAST PSC-TC
-                    /*gPC.puts("checking for tc list complete\r\n");*/
+                    if (DEBUG)
+                        gPC.puts("checking for tc list complete\r\n");
                     uint8_t tempContinue = 0xFF;
                     continueToExecute(tempContinue);
                     if(tempContinue == 0x00){
-                        /*gPC.puts("tc list is complete\r\n");*/
+                        if (DEBUG)
+                            gPC.puts("tc list is complete\r\n");
                         // CHECK WEATHER GS VERIFICATION CODE MATCHES
                         uint8_t tempGSver = 0x00;
                         GScodeVerification(tempGSver);
                         /*PENDING: INCLUDE GS VERIFICATION CODE*/
                         if( tempGSver == 0xFF ){
-                            /*gPC.puts("GS code match !!\r\n");*/
+                            if (DEBUG)
+                                gPC.puts("GS code match !!\r\n");
                             gFLAGS = gFLAGS | COM_SESSION_VALIDITY;
                             COM_POWER_ON_TX;
                             // PENDING: PA HOT HANDLED IN EXECUTE_XXX FUNCTIONS
@@ -148,11 +151,13 @@
                             if( tempPAHot == 0xFF ){
                                 gFLAGS = gFLAGS & ~(COM_PA_HOT_FLAG);
                                 gCOM_PA_COOLING_TIMEOUT.detach();
-                                gPC.puts("EXECUTING TELECOMMANDS\r\n");
-//                                DEBUF_PRINT("EXECUTING TELECOMMANDS\r\n");
+                                if (DEBUG)
+                                    gPC.puts("EXECUTING TELECOMMANDS\r\n");
+//                              DEBUF_PRINT("EXECUTING TELECOMMANDS\r\n");
                                 EXECUTE_OBOSC_ONLY;
                                 EXECUTE_TC;
-                                /*gPC.puts("COMPLETED EXECUTION\r\n");*/
+                                if (DEBUG)
+                                    gPC.puts("COMPLETED EXECUTION\r\n");
                             }
                             else{
                                 gFLAGS = gFLAGS | COM_PA_HOT_FLAG;
@@ -163,7 +168,8 @@
                             }
                         }
                         else{
-                            /*gPC.puts("GS code mismatch !!\r\n");*/
+                            if(DEBUG)
+                                gPC.puts("GS code mismatch !!\r\n");
                             RX1M.attach(&rx_read, Serial::RxIrq);
                             reset_all;
                             gFLAGS = gFLAGS & (~COM_SESSION_VALIDITY);
@@ -175,16 +181,22 @@
                         }
                     }
                     else{
-                        //gPC.puts("tc list is not complete\r\n");
+                        if (DEBUG)
+                            gPC.puts("tc list is not complete\r\n");
                         if(tempContinue & 0x01){
-                            //gPC.puts("last packet bit not found\r\n");
+                            if (DEBUG)
+                                gPC.puts("last packet bit not found\r\n");
                         }
                         if( tempContinue & 0x02 ){
-                            //gPC.puts("missing psc found\r\n");
+                            if (DEBUG)
+                                gPC.puts("missing psc found\r\n");
                         }
-                        //gPC.printf("crc fail tc = %u\r\n", gTOTAL_CRC_FAIL_TC);
-                        //gPC.printf("incorrect size tc = %u\r\n", gTOTAL_INCORRECT_SIZE_TC);
-                        //gPC.printf("repeated psc = %u\r\n", gTOTAL_REPEATED_TC);
+                        if (DEBUG){
+                            gPC.printf("crc fail tc = %u\r\n", gTOTAL_CRC_FAIL_TC);
+                            gPC.printf("incorrect size tc = %u\r\n", gTOTAL_INCORRECT_SIZE_TC);
+                            gPC.printf("repeated psc = %u\r\n", gTOTAL_REPEATED_TC);    
+                            gPC.puts("\r\n");
+                        }
                         Base_tc *test_tc = gHEAD_NODE_TCL;
                         while( test_tc != NULL ){
                             int length = 0;
@@ -195,9 +207,13 @@
                                 length = TC_LONG_SIZE;
                             }
                             for(int i = 0 ; i < length ; ++i ){
-                                //gPC.printf("%x ", test_tc->TC_string[i]);
+                                int x = 128;
+                                for( int j = 7 ; j >= 0 ; --j ){
+                                    gPC.printf("%d", (test_tc->TC_string[i] & x)>>j);
+                                    x = x/2;
+                                }
                             }
-                            //gPC.puts("\r\n");
+                            gPC.puts("\r\n");
                             test_tc = test_tc->next_TC;
                         }
                         //gPC.puts("\r\n");
@@ -216,7 +232,8 @@
                 }
             }
             else{
-                /*gPC.puts("No valid TC received\r\n");*/
+                if (DEBUG)
+                    gPC.puts("No valid TC received\r\n");
                 RX1M.attach(&rx_read, Serial::RxIrq);
                 gFLAGS = gFLAGS & (~COM_MNG_TMTC_RUNNING_FLAG);
                 reset_all;
@@ -227,7 +244,8 @@
             }
         }
         else if( gFLAGS & COM_PA_HOT_FLAG ){
-            /*gPC.puts("checking for PA hot in main\r\n");*/
+            if (DEBUG)
+                gPC.puts("checking for PA hot in main\r\n");
             if( gFLAGS & COM_RX_FLAG ){
                 uint8_t tempPA = 0xFF;
                 isPAhot(tempPA);
@@ -258,7 +276,8 @@
             }
         }
         else if( gFLAGS & COM_SESSION_TIMEOUT_FLAG ){
-            /*gPC.puts("session timeout: resetting in main\r\n");*/
+            if (DEBUG)
+                gPC.puts("session timeout: resetting in main\r\n");
             COM_POWER_OFF_TX;
             /*PENDING : ENABLE THREADS*/
             gPAY_SPI.bulkRead_start();
@@ -268,7 +287,8 @@
             reset_all;
         }
         else{
-            /*gPC.puts("INVALID SIGNAL RECEIVED IN MAIN\r\n");*/
+            if (DEBUG)
+                gPC.puts("INVALID SIGNAL RECEIVED IN MAIN\r\n");
             // SOME INVALID SIGNAL RECEIVED
             COM_POWER_OFF_TX;
             reset_all;
@@ -293,7 +313,7 @@
     gPAY_SPI.bulkRead_start();
      
     while(true){
-        gPC.puts("entering sci\r\n");
+        gPC.puts("entering science thread\r\n");
         gSCIENCE_THREAD->signal_wait(SCIENCE_SIGNAL);
         gPC.puts("sig_set\r\n");
         srp(gPAYLOAD_BUFFER);