Correction needed to make TX and RX integration work
diff --git a/grc/transmitter/gsm_txtime_bursts_tagger.xml b/grc/transmitter/gsm_txtime_bursts_tagger.xml
index 8c3a203..4012c17 100644
--- a/grc/transmitter/gsm_txtime_bursts_tagger.xml
+++ b/grc/transmitter/gsm_txtime_bursts_tagger.xml
@@ -9,8 +9,8 @@
   <param>
     <name>init_fn</name>
     <key>init_fn</key>
-    <value>0</value>
-    <type>int</type>
+    <value>None</value>
+    <type>raw</type>
     <hide>part</hide>
   </param>
 
diff --git a/lib/receiver/receiver_impl.cc b/lib/receiver/receiver_impl.cc
index db7d9dd..d57b4a1 100644
--- a/lib/receiver/receiver_impl.cc
+++ b/lib/receiver/receiver_impl.cc
@@ -74,6 +74,7 @@
     ) : gr::sync_block("receiver",
           gr::io_signature::make(1, -1, sizeof(gr_complex)),
           gr::io_signature::make(0, 0, 0)),
+        d_samples_consumed(0),
         d_rx_time_received(false),
         d_time_samp_ref(GSM_SYMBOL_RATE * osr),
         d_OSR(osr),
@@ -183,21 +184,8 @@
       /* And storing it in time_sample_ref for sample number to time conversion */
       std::vector<tag_t> rx_time_tags;
 
-      get_tags_in_window(rx_time_tags, 0, 0, noutput_items, pmt::string_to_symbol("rx_time"));
-      if(!rx_time_tags.empty()){
-        d_rx_time_received = true;
-        tag_t rx_time_tag = *(rx_time_tags.begin());
-
-        uint64_t rx_time_full_part = to_uint64(tuple_ref(rx_time_tag.value,0));
-        double rx_time_frac_part = to_double(tuple_ref(rx_time_tag.value,1));
-        
-        time_spec_t current_rx_time = time_spec_t(rx_time_full_part, rx_time_frac_part);
-        uint64_t current_start_offset = rx_time_tag.offset;
-        d_time_samp_ref.update(current_rx_time, current_start_offset);
-//        std::cout << "Mam rx_time: " << current_rx_time.get_real_secs() << std::endl;
-      }
-      
       /* Main state machine */
+      d_samples_consumed = 0;
       switch (d_state) {
       case fcch_search:
         fcch_search_handler(input, noutput_items);
@@ -210,7 +198,21 @@
         break;
       }
 
-      return 0;
+      get_tags_in_window(rx_time_tags, 0, 0, d_samples_consumed, pmt::string_to_symbol("rx_time"));
+      if(!rx_time_tags.empty()){
+        d_rx_time_received = true;
+        tag_t rx_time_tag = *(rx_time_tags.begin());
+
+        uint64_t rx_time_full_part = to_uint64(tuple_ref(rx_time_tag.value,0));
+        double rx_time_frac_part = to_double(tuple_ref(rx_time_tag.value,1));
+        
+        time_spec_t current_rx_time = time_spec_t(rx_time_full_part, rx_time_frac_part);
+        uint64_t current_start_offset = rx_time_tag.offset;
+        d_time_samp_ref.update(current_rx_time, current_start_offset);
+        std::cout << "Mam rx_time: " << current_rx_time.get_real_secs() << std::endl;
+      }
+
+      return d_samples_consumed;
     }
 
     void
@@ -270,7 +272,9 @@
       d_burst_nr++;
 
       /* Consume samples up to the next guard period */
-      consume_each(burst_start + BURST_SIZE * d_OSR + 4 * d_OSR);
+      unsigned int to_consume = burst_start + BURST_SIZE * d_OSR + 4 * d_OSR;
+//      consume_each(to_consume);
+      d_samples_consumed += to_consume;
 
       /* Update current state */
       d_state = synchronized;
@@ -505,7 +509,8 @@
 
           /* Consume samples of the burst up to next guard period */
           to_consume += TS_BITS * d_OSR + d_burst_nr.get_offset();
-          consume_each(to_consume);
+//          consume_each(to_consume);
+          d_samples_consumed += to_consume;
         }
       }
     }
@@ -696,7 +701,8 @@
       }
 
       d_counter += to_consume;
-      consume_each(to_consume);
+//      consume_each(to_consume);
+      d_samples_consumed += to_consume;
 
       return result;
     }
@@ -747,7 +753,8 @@
       }
 
       d_counter += to_consume;
-      consume_each(to_consume);
+//      consume_each(to_consume);
+      d_samples_consumed += to_consume;
 
       return result;
     }
@@ -1047,8 +1054,11 @@
         time_spec_t time_spec_of_first_sample = d_time_samp_ref.offset_to_time(nitems_read(0)+burst_start);
         uint64_t full = time_spec_of_first_sample.get_full_secs();
         double   frac = time_spec_of_first_sample.get_frac_secs();
-        pdu_header    = 
-          pmt::dict_add(pdu_header, pmt::mp("fn_time"), pmt::cons(pmt::from_uint64(frame_number), pmt::cons(pmt::from_uint64(full), pmt::from_double(frac))));
+        pdu_header = 
+          pmt::dict_add(pdu_header, pmt::mp("fn_time"), 
+            pmt::cons(
+              pmt::cons(pmt::from_uint64(be32toh(frame_number)), pmt::from_uint64(tn)),
+              pmt::cons(pmt::from_uint64(full), pmt::from_double(frac))));
       }
 
       /* Copy burst to the buffer */
@@ -1056,7 +1066,7 @@
 
       /* Allocate a new message */
       pmt::pmt_t blob = pmt::make_blob(buf, sizeof(gsmtap_hdr) + BURST_SIZE);
-      pmt::pmt_t msg = pmt::cons(pmt::PMT_NIL, blob);
+      pmt::pmt_t msg = pmt::cons(pdu_header, blob);
 
       /* Send message */
       if (input_nr == 0)
diff --git a/lib/receiver/receiver_impl.h b/lib/receiver/receiver_impl.h
index 4972b62..d43bb27 100644
--- a/lib/receiver/receiver_impl.h
+++ b/lib/receiver/receiver_impl.h
@@ -35,6 +35,7 @@
     class receiver_impl : public receiver
     {
      private:
+        unsigned int d_samples_consumed;
         bool d_rx_time_received;
         time_sample_ref d_time_samp_ref;
         unsigned int d_c0_burst_start;
diff --git a/python/transmitter/txtime_bursts_tagger.py b/python/transmitter/txtime_bursts_tagger.py
index f587f43..489af2a 100644
--- a/python/transmitter/txtime_bursts_tagger.py
+++ b/python/transmitter/txtime_bursts_tagger.py
@@ -47,25 +47,33 @@
         self.set_msg_handler(pmt.intern("bursts"), self.process_txtime_of_burst)
         
     def process_fn_time_reference(self, msg):
-        time_hint = pmt.to_python(pmt.dict_ref(pmt.car(msg), (pmt.intern("time_hint"),PMT_NIL)))
-        fn_time = pmt.to_python(pmt.dict_ref(pmt.car(msg), (pmt.intern("fn_time"),PMT_NIL)))
+        time_hint = pmt.to_python(pmt.dict_ref(msg, pmt.intern("time_hint"), pmt.PMT_NIL))
+        fn_time = pmt.to_python(pmt.dict_ref(msg, pmt.intern("fn_time"), pmt.PMT_NIL))
+
+#        if self.fn_ref is None:
         if time_hint is not None:
             self.time_hint = time_hint
         elif fn_time is not None:
-            self.fn_ref = pmt.car(fn_time)
-            self.time_ref = pmt.cdr(fn_time)
+            self.fn_ref = fn_time[0][0]
+            self.ts = fn_time[0][1]
+            full = fn_time[1][0]
+            frac = fn_time[1][1]
+        
+            self.time_ref = full+frac
             self.time_hint = self.time_ref
              
     def process_txtime_of_burst(self, msg):
         burst_with_header = pmt.to_python(pmt.cdr(msg))
         fn = burst_with_header[11]+burst_with_header[10]*2**8+burst_with_header[9]*2**16+burst_with_header[8]*2**24
         ts_num = burst_with_header[3]
-        fn_delta, txtime = fn_time_delta(self.fn_ref, self.time_ref, fn, self.time_hint, ts_num)
-        txtime_secs = int(txtime)
-        txtime_fracs = txtime-int(txtime)
-        tags_dict = pmt.dict_add(pmt.make_dict(), pmt.intern("tx_time"), pmt.make_tuple(pmt.from_uint64(txtime_secs),pmt.from_double(txtime_fracs)))
-        new_msg = pmt.cons(tags_dict, pmt.cdr(msg))
-        self.message_port_pub(pmt.intern("bursts"), new_msg)
+        if self.fn_ref is not None:
+          fn_delta, txtime = fn_time_delta(self.fn_ref, self.time_ref, fn, self.time_hint, ts_num)
+          txtime_secs = int(txtime)
+          txtime_fracs = txtime-int(txtime)
+          #print "txtime_secs",txtime_secs,"txtime_fracs",txtime_fracs
+          tags_dict = pmt.dict_add(pmt.make_dict(), pmt.intern("tx_time"), pmt.make_tuple(pmt.from_uint64(txtime_secs),pmt.from_double(txtime_fracs)))
+          new_msg = pmt.cons(tags_dict, pmt.cdr(msg))
+          self.message_port_pub(pmt.intern("bursts"), new_msg)
         
     def set_fn_time_reference(self, init_fn, init_time):
         self.fn_ref = init_fn