pl ack in tmtc

Dependencies:   FreescaleIAP SimpleDMA mbed-rtos mbed

Fork of COM_MNG_TMTC_SIMPLE_pl123 by shubham c

Revision:
31:470cfff32c3c
Parent:
30:154938956d89
Child:
32:325359eb8d5c
--- a/COM_SND_TM.h	Sun Jan 03 17:02:18 2016 +0000
+++ b/COM_SND_TM.h	Mon Jan 04 13:08:34 2016 +0000
@@ -83,9 +83,8 @@
         if(SEGMENT_NO > MAX_SEGMENT)
         {
             SEGMENT_NO = MAX_SEGMENT;
-            segment_r = 1;
         }
-        else segment_r = 0;
+        if(SEGMENT_NO == 1) segment_r = 0; else segment_r = 1;
         TOTAL_SEGMENT_NO -= SEGMENT_NO;
         LAST_SEGMENT_SIZE = total_frames*2%ISR?total_frames*2%ISR:ISR;
     }
@@ -174,36 +173,8 @@
             }\
         }\
         ptr=TMframe_type1;\
-    }
- 
- 
-//    unsigned char * type1_frame(){
-//        int i=4;
-//        if(type1_frame_flag){
-//            T1F_pointer = first_type_structure(1);
-//            T1F_counter = 0;
-//            type1_frame_flag = false;
-//        }
-//        for(i = 4 ; (i < 134) && (T1F_pointer != NULL) ; i++){
-//             TMframe_type1[i] = T1F_pointer->TM_string[T1F_counter];
-//              if(T1F_counter++ == 12){
-//                T1F_counter = 0;
-//                T1F_pointer = next_type_structure(T1F_pointer);
-//              }
-//        }
-//        // header
-//        TMframe_type1[0] = 1<<7 + ( (i-4)/10 )<<3;                          //( (i-4)/10 ) gives number of packets in the frame
-//            //insert time ;
-//        TMframe_type1[3] = CRC::crc16_gen(TMframe_type1,3);
-//        //end header
-//        if(T1F_pointer == NULL && i>12){
-//            for( ; i < 134 ; i++){                                          //repeating ;ast packet to fill up the extra space
-//                TMframe_type1[i] = TMframe_type1[i-13];
-//            }
-//        }
-//        return TMframe_type1;
-//    }
- 
+    } 
+
     bool type0_frame_flag;
  
  
@@ -218,18 +189,6 @@
         ptr =  T0F_pointer->TM_string;\
     }
  
- 
-//    unsigned char* type0_frame(){
-//        if(type0_frame_flag){
-//            T0F_pointer = first_type_structure(0);
-//            type0_frame_flag = false;
-//        }
-//        else {
-//            T0F_pointer = next_type_structure(T0F_pointer);
-//        }
-//        return T0F_pointer->TM_string;
-//    }
- 
     unsigned char convoluted_frame[270];
     Convolution ConvObj2;
     void convolution (unsigned char * ptr){
@@ -281,9 +240,7 @@
         bool reset_adf;
         SND_TM(){
             MAX_SEGMENT = (MAX_ADF_LEN-EOS_SIZE)/( S_FRAME_SIZE + ISR*T_FRAME_SIZE);
-            //MAX_SEGMENT = 1;
                             //(max length - eos size)/(sframe length + tFrameLength*ISR)
-//            cout<<int(MAX_SEGMENT)<<endl;
         }
  
  
@@ -296,8 +253,6 @@
             transmit_data_f = true;
             diff_prev = 0;
             data_number();
-           // make_DataStream;
-//            gPC.putc('z');
         }
  
  
@@ -393,6 +348,7 @@
                         else{
                             Tframe_c = 0;
                             segment_c++;
+                            if(segment_c == SEGMENT_NO - 1 && TOTAL_SEGMENT_NO == 0) segment_r = 0; else segment_r = 1;
                             if(segment_c == SEGMENT_NO)
                                 {eos_f = true;}
                             else{
@@ -408,15 +364,6 @@
                     if(EOS_c == EOS_SIZE){
                         EOS_c = 0;
                         eos_f = false;
- //                     printf("exit EOS\n");
-//                        if(segment_c == MAX_SEGMENT){
-//                            segment_c = 0;
-//                            SEGMENT_NO = SEGMENT_NO - MAX_SEGMENT;
-//                            reset_adf = true;//what does this do??
-//                            Sframe = true;
-//                        }else{
-//                            *last_buffer = true;
-//                        }
                         if(segment_c == SEGMENT_NO && segment_r == 0){
                               *last_buffer = true;
                                 }
@@ -426,9 +373,8 @@
                                 if(SEGMENT_NO > MAX_SEGMENT)
                                 {
                                     SEGMENT_NO = MAX_SEGMENT;
-                                    segment_r = 1;
                                 }
-                                else segment_r = 0;
+                                if(SEGMENT_NO == 1) segment_r = 0; else segment_r = 1; 
                                 TOTAL_SEGMENT_NO -= SEGMENT_NO;
                                 reset_adf = true;//what does this do??
                                 Sframe = true;