working version

Dependencies:   mbed mbed-rtos SimpleDMA FreescaleIAP eeprom

Fork of CDMS_CODE_FM_28JAN2017 by samp Srinivasan

Revision:
236:ccbd1a7778b1
Parent:
233:bfce738e43e8
--- a/COM_MNG_TMTC.h	Wed Jul 06 08:09:22 2016 +0000
+++ b/COM_MNG_TMTC.h	Wed Jul 06 21:25:51 2016 +0000
@@ -15,19 +15,19 @@
 //DigitalIn tm_status_4m_slv(PIN39); //I2C interrupt to CDMS from BAE
 //DigitalIn tm_status_4m_pl(PIN61); //I2C interrupt to CDMS from PL
 #define RESET_CDMS NVIC_SystemReset()
-
-#define BAE_TC{\
+#define BAE_TC_ENABLE 1 
+#define BAE_TC {\
     tc_ptr->next_TC = NULL;\
     PUTshort_or_long(tc_ptr,SHORT_TC_CODE);\
     PUTcrc_pass(tc_ptr,0x1);\
     PUTexec_status(tc_ptr,0);\
-    tc_ptr->TC_string[0] = 0x01;\
-    tc_ptr->TC_string[1] = 0x60;\
-    tc_ptr->TC_string[2] = 0x81;\
-    tc_ptr->TC_string[3] = 0x21;\
-    tc_ptr->TC_string[4] = 0x00;\
-    tc_ptr->TC_string[5] = 0;\
-    tc_ptr->TC_string[6] = 0;\
+    /*tc_ptr->TC_string[0] = 0x01;*/\
+    /*tc_ptr->TC_string[1] = 0x60;*/\
+    /*tc_ptr->TC_string[2] = 0x81;*/\
+    /*tc_ptr->TC_string[3] = 0x40;*/\
+    tc_ptr->TC_string[4] = 0x01;\
+    tc_ptr->TC_string[5] = 0x01;\
+    tc_ptr->TC_string[6] = 0x01;\
     tc_ptr->TC_string[7] = 0;\
     tc_ptr->TC_string[8] = 0;\
     uint16_t crc16 = crc16_gen(tc_ptr->TC_string, 9);\
@@ -378,7 +378,9 @@
         case 1: //apid=01 implies it corresponds to bae
         {
             BAE_I2C_mutex.lock();
+            #if BAE_TC_ENABLE
             BAE_TC;
+            #endif
             gPC.printf("Telecommand is for BAE\r\n");
             gPC.printf("Sending TC to BAE...\r\n"); //interrupt to be sent to the bae
             y = FCTN_I2C_WRITE((char*)tc_ptr->TC_string,TC_LONG_SIZE);                         // Check for SHORT and LONG TC and then send
@@ -404,6 +406,11 @@
                     y=FCTN_I2C_READ((char*)tm_pointer->TM_string,TM_LONG_SIZE);            //rify later about the size
                     if(y==0)
                     {
+                        gPC.printf("TM\n\r : ");
+                        for(int i = 0; i<134 ; i++)
+                        {
+                            gPC.printf("0x%02X",tm_pointer->TM_string[i]);
+                            }
                         tm_pointer->next_TM=NULL;
                         return tm_ptr;
                     }
@@ -1188,11 +1195,14 @@
         Base_tc* current_TC = gHEAD_NODE_TCL;\
         int overflowCount = 0;\
         while(current_TC != NULL){\
+            gPC.printf("current_TC\r\n");\
             if( overflowCount < TCL_OVERFLOW_CONSTANT ){\
+                gPC.printf("overflow Count\r\n");\
                 if( (GETcrc_pass(current_TC) == 1) && (GETpacket_seq_count(current_TC) == execute_psc) ){\
+                    gPC.printf("==1 and execute_psc\r\n");\
                     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);*/\
+                        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;\
@@ -1200,7 +1210,7 @@
                         break;\
                     }\
                     else if( (current_exec_status == TC_STATE_EXECUTION_FAILED) && (GETabort_on_nack(current_TC) == 1) ){\
-                        /*gPC.printf("abort on nack at %u psc\r\n", execute_psc);*/\
+                        gPC.printf("abort on nack at %u psc\r\n", execute_psc);\
                         gMASTER_STATE = TCL_STATE_ABORTED;\
                         Base_tm *tm_ptr_head = NULL;\
                         get_call_sign(tm_ptr_head);\
@@ -1215,7 +1225,7 @@
                             else{\
                                 length = TM_LONG_SIZE;\
                             }\
-                            /*gPC.puts("Printing Call Sign, ACK_L1, TM list");*/\
+                            gPC.puts("Printing Call Sign, ACK_L1, TM list");\
                             for(int i = 0 ; i < length ; ++i){\
                                 /*gPC.putc(tm_ptr->TM_string[i]);*/\
                             }\
@@ -1256,13 +1266,13 @@
                             uint8_t tempPAhot = 0x00;\
                             isit_obosc(current_TC, temp82);\
                             if(temp82 == 0x01){\
-                                /*gPC.printf("obosc tc inside normal tc at %u\r\n", execute_psc);*/\
+                                gPC.printf("obosc tc inside normal tc at %u\r\n", execute_psc);\
                                 /*EXECUTION OF OBOSC TC*/\
                                 /*SKIP EXECUTION OF OBOSC HERE*/\
                                 break;\
                             }\
                             else{\
-                                /*gPC.printf("cdms relay tmtc at %u\r\n", execute_psc);*/\
+                                gPC.printf("cdms relay tmtc at %u\r\n", execute_psc);\
                                 /*call CDMS_RLY_TMTC*/\
                                 /*CDMS_RLY_TMTC(current_TC, put_tm_here);*/\
                                 put_tm_here =  FCTN_CDMS_RLY_TMTC(current_TC);\
@@ -1276,7 +1286,7 @@
                                 PUTexec_status(current_TC, temp16);\
                             }\
                             else{\
-                                /*gPC.puts("TC_STATE_EXECUTION_FAILED");*/\
+                                gPC.puts("TC_STATE_EXECUTION_FAILED");\
                                 uint16_t temp16 = TC_STATE_EXECUTION_FAILED;\
                                 PUTexec_status(current_TC, temp16);\
                             }\
@@ -1471,8 +1481,10 @@
                             }\
                         }\
                     }\
+                    gPC.printf("break\r\n");\
                     break;\
                 }\
+                gPC.printf("current->next\r\n");\
                 current_TC = current_TC->next_TC;\
                 ++overflowCount;\
             }\
@@ -1481,6 +1493,7 @@
                 break;\
             }\
         }\
+        gPC.printf("after CDMS_RESET\r\n");\
         if( gFLAGS & COM_SESSION_TIMEOUT_FLAG ){\
             break;\
         }\