pl ack in tmtc

Dependencies:   FreescaleIAP SimpleDMA mbed-rtos mbed

Fork of COM_MNG_TMTC_SIMPLE_pl123 by shubham c

Revision:
4:104dd82c99b8
Parent:
2:2caf2a9a13aa
Child:
5:ab276a17ca07
--- a/COM_RCV_TC.h	Wed Dec 23 05:37:55 2015 +0000
+++ b/COM_RCV_TC.h	Tue Dec 29 06:50:19 2015 +0000
@@ -1,15 +1,17 @@
 #define flushData_appendTC(bytes, outState) {\
     uint16_t tc_type = 2;\
     if( (bytes == TC_SHORT_SIZE) && (outState == 7) ){\
-        tc_type = 0;\
+        tc_type = SHORT_TC_CODE;\
     }\
     else if( (bytes == TC_LONG_SIZE) && (outState == 7) ){\
-        tc_type = 1;\
+        tc_type = LONG_TC_CODE;\
     }\
     else{\
+        gPC.puts("incorrect size\r\n");\
+        gPC.printf("%u, %u\r\n", bytes, outState);\
         ++gTOTAL_INCORRECT_SIZE_TC;\
     }\
-    if( tc_type == 0 ){\
+    if( tc_type == SHORT_TC_CODE ){\
         uint16_t crc_checksum = crc16_gen(rx_tempString, TC_SHORT_SIZE-2);\
         if( ( (crc_checksum & 0xFF) == rx_tempString[TC_SHORT_SIZE-1]) && ( ((crc_checksum >> 8) & 0xFF) == rx_tempString[TC_SHORT_SIZE-2] ) ){\
             uint16_t temp16;\
@@ -24,6 +26,7 @@
                 temp_ptr = temp_ptr->next_TC;\
             }\
             if( repeat_flag == false ){\
+                gPC.puts("Found short tc\e\n");\
                 if( rx_tc_frames == 0 ){\
                     gHEAD_NODE_TCL = new Short_tc;\
                     gHEAD_NODE_TCL->next_TC = NULL;\
@@ -31,11 +34,13 @@
                 }\
                 else{\
                     gLAST_NODE_TCL->next_TC = new Short_tc;\
-                    gLAST_NODE_TCL = gLAST_NODE_TCL;\
+                    gLAST_NODE_TCL = gLAST_NODE_TCL->next_TC;\
                     gLAST_NODE_TCL->next_TC = NULL;\
                 }\
+                gPC.puts("printing tx string\r\n");\
                 for(int i = 0 ; i < TC_SHORT_SIZE ; ++i){\
                     gLAST_NODE_TCL->TC_string[i] = rx_tempString[i];\
+                    gPC.printf("%x ", gLAST_NODE_TCL->TC_string[i]);\
                 }\
                 PUTshort_or_long(gLAST_NODE_TCL, tc_type);\
                 temp16 = 1;\
@@ -45,14 +50,16 @@
                 ++gTOTAL_VALID_TC;\
             }\
             else{\
+                gPC.puts("repeated psc short\r\n");\
                 ++gTOTAL_REPEATED_TC;\
             }\
         }\
         else{\
+            gPC.puts("crc fail tc short");\
             ++gTOTAL_CRC_FAIL_TC;\
         }\
     }\
-    else if( tc_type == 1 ){\
+    else if( tc_type == LONG_TC_CODE ){\
         uint16_t crc_checksum = crc16_gen(rx_tempString, TC_LONG_SIZE-2);\
         if( ( (crc_checksum & 0xFF) == rx_tempString[TC_LONG_SIZE-1]) && ( ((crc_checksum >> 8) & 0xFF) == rx_tempString[TC_LONG_SIZE-2] ) ){\
             uint16_t temp16;\
@@ -67,6 +74,7 @@
                 temp_ptr = temp_ptr->next_TC;\
             }\
             if( repeat_flag == false ){\
+                gPC.puts("Found lling tc\e\n");\
                 if( rx_tc_frames == 0 ){\
                     gHEAD_NODE_TCL = new Long_tc;\
                     gHEAD_NODE_TCL->next_TC = NULL;\
@@ -79,6 +87,7 @@
                 }\
                 for(int i = 0 ; i < TC_LONG_SIZE ; ++i){\
                     gLAST_NODE_TCL->TC_string[i] = rx_tempString[i];\
+                    gPC.printf("%x ", gLAST_NODE_TCL->TC_string[i]);\
                 }\
                 PUTshort_or_long(gLAST_NODE_TCL, tc_type);\
                 temp16 = 1;\
@@ -88,10 +97,12 @@
                 ++gTOTAL_VALID_TC;\
             }\
             else{\
+                gPC.puts("repeated psc long\r\n");\
                 ++gTOTAL_REPEATED_TC;\
             }\
         }\
         else{\
+            gPC.puts("crc fail tc long");\
             ++gTOTAL_CRC_FAIL_TC;\
         }\
     }\
@@ -102,6 +113,7 @@
 unsigned char rx_tempString[TC_LONG_SIZE+1];
 
 void raw_data_to_tc(void){
+    gPC.puts("inside raw_data_to_tc\r\n");
     bool frame_started = false;
     bool chain_started = false;
     bool flush_called = false;
@@ -114,9 +126,6 @@
     
     gTOTAL_VALID_TC = 0;
     
-    gOBOSC_PSC = PSC_START_VALUE + gTOTAL_VALID_TC - 1;
-    gOBOSC_HEAD = gLAST_NODE_TCL;
-    
     COM_RX_DATA_NODE *data_node = gRX_HEAD_DATA_NODE;
     // read byte by byte
     while( data_node != NULL ){
@@ -258,12 +267,6 @@
     gRX_CURRENT_DATA_NODE = gRX_HEAD_DATA_NODE;
     gRX_COUNT = 0;
     
-    if( gOBOSC_HEAD != NULL ){
-        gOBOSC_HEAD = gOBOSC_HEAD->next_TC;
-        if( gOBOSC_HEAD != NULL ){
-            ++gOBOSC_PSC;
-        }
-    }
-    
+    gPC.puts("Completed conversion of raw_data\r\n");
     // PENDING: SORT THE LINKED LIST ACCORDING TO PSC VALUE
 }
\ No newline at end of file