commit-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Commit-gnuradio] r11221 - in gnuradio/branches/developers/eb/vrt: gr-vr


From: eb
Subject: [Commit-gnuradio] r11221 - in gnuradio/branches/developers/eb/vrt: gr-vrt/src vrt/include/vrt vrt/lib
Date: Wed, 17 Jun 2009 13:20:58 -0600 (MDT)

Author: eb
Date: 2009-06-17 13:20:57 -0600 (Wed, 17 Jun 2009)
New Revision: 11221

Modified:
   gnuradio/branches/developers/eb/vrt/gr-vrt/src/missing_pkt_checker.cc
   gnuradio/branches/developers/eb/vrt/gr-vrt/src/missing_pkt_checker.h
   gnuradio/branches/developers/eb/vrt/gr-vrt/src/vrt_quadradio_source_32fc.cc
   gnuradio/branches/developers/eb/vrt/vrt/include/vrt/rx.h
   gnuradio/branches/developers/eb/vrt/vrt/include/vrt/rx_packet_handler.h
   gnuradio/branches/developers/eb/vrt/vrt/lib/rx.cc
   gnuradio/branches/developers/eb/vrt/vrt/lib/rx_packet_handler.cc
Log:
Drop stale packets before (re)starting.


Modified: gnuradio/branches/developers/eb/vrt/gr-vrt/src/missing_pkt_checker.cc
===================================================================
--- gnuradio/branches/developers/eb/vrt/gr-vrt/src/missing_pkt_checker.cc       
2009-06-17 19:08:07 UTC (rev 11220)
+++ gnuradio/branches/developers/eb/vrt/gr-vrt/src/missing_pkt_checker.cc       
2009-06-17 19:20:57 UTC (rev 11221)
@@ -32,7 +32,7 @@
   int nmissing = 0;
   int actual = hdr->pkt_cnt();
   int expected = (d_last_pkt_cnt + 1) & 0xf;
-  if (d_npackets != 0 && actual != expected){
+  if (actual != expected && !d_resync){
     d_nwrong_pkt_cnt++;
     if (actual > expected)
       nmissing = actual - expected;
@@ -42,5 +42,6 @@
   }
   d_last_pkt_cnt = actual;
   d_npackets++;
+  d_resync = false;
   return nmissing;
 }

Modified: gnuradio/branches/developers/eb/vrt/gr-vrt/src/missing_pkt_checker.h
===================================================================
--- gnuradio/branches/developers/eb/vrt/gr-vrt/src/missing_pkt_checker.h        
2009-06-17 19:08:07 UTC (rev 11220)
+++ gnuradio/branches/developers/eb/vrt/gr-vrt/src/missing_pkt_checker.h        
2009-06-17 19:20:57 UTC (rev 11221)
@@ -31,6 +31,7 @@
 {
   // FIXME assumes we're inspecting only a single stream
 
+  bool         d_resync;
   uint64_t     d_npackets;             //< total number of packets
   int          d_last_pkt_cnt;         //< the last pkt_cnt we saw
   uint64_t     d_nwrong_pkt_cnt;       //< number of incorrect pkt_cnt
@@ -38,13 +39,15 @@
   
 public:
   missing_pkt_checker()
-    : d_npackets(0), d_last_pkt_cnt(0xf), d_nwrong_pkt_cnt(0), 
d_nmissing_pkt_est(0) {}
+    : d_resync(true), d_npackets(0), d_last_pkt_cnt(0xf), d_nwrong_pkt_cnt(0),
+      d_nmissing_pkt_est(0) {}
     
   /*!
    * \brief check header pkt_cnt and return 0 if OK, else estimate of number 
of missing packets.
    */
   int check(const vrt::expanded_header *hdr);
 
+  void resync() { d_resync = true; }
   uint64_t npackets() const { return d_npackets; }
   uint64_t nwrong_pkt_cnt() const { return d_nwrong_pkt_cnt; }
   uint64_t nmissing_pkt_est() const { return d_nmissing_pkt_est; }

Modified: 
gnuradio/branches/developers/eb/vrt/gr-vrt/src/vrt_quadradio_source_32fc.cc
===================================================================
--- gnuradio/branches/developers/eb/vrt/gr-vrt/src/vrt_quadradio_source_32fc.cc 
2009-06-17 19:08:07 UTC (rev 11220)
+++ gnuradio/branches/developers/eb/vrt/gr-vrt/src/vrt_quadradio_source_32fc.cc 
2009-06-17 19:20:57 UTC (rev 11221)
@@ -23,6 +23,7 @@
 #endif
 #include <vrt_quadradio_source_32fc.h>
 #include <vrt/quadradio.h>
+#include <vrt/rx_packet_handler.h>
 
 vrt_quadradio_source_32fc_sptr
 vrt_make_quadradio_source_32fc(const std::string &ip, size_t rx_bufsize)
@@ -51,6 +52,11 @@
 bool 
 vrt_quadradio_source_32fc::start()
 {
+  // throw away any stale packets before starting
+  vrt::rx_packet_handler nop;
+  vrt_rx()->rx_packets(&nop, true);
+  d_checker.resync();
+
   return d_qr->start_streaming(d_samples_per_pkt);
 }  
 

Modified: gnuradio/branches/developers/eb/vrt/vrt/include/vrt/rx.h
===================================================================
--- gnuradio/branches/developers/eb/vrt/vrt/include/vrt/rx.h    2009-06-17 
19:08:07 UTC (rev 11220)
+++ gnuradio/branches/developers/eb/vrt/vrt/include/vrt/rx.h    2009-06-17 
19:20:57 UTC (rev 11221)
@@ -76,10 +76,11 @@
     /*!
      * \brief Receive packets from the given socket file descriptor.
      *
-     * Handler will be invoked for all available packets.
-     * This function blocks until at least one packet has been processed.
+     * \p handler will be invoked for all available packets.
+     * Unless \p dont_wait is true, this function blocks until at
+     * least one packet has been processed.
      */
-    bool rx_packets(rx_packet_handler *handler);
+    bool rx_packets(rx_packet_handler *handler, bool dont_wait = false);
 
     /*
      * \returns the socket_fd.   Useful for select or poll.

Modified: 
gnuradio/branches/developers/eb/vrt/vrt/include/vrt/rx_packet_handler.h
===================================================================
--- gnuradio/branches/developers/eb/vrt/vrt/include/vrt/rx_packet_handler.h     
2009-06-17 19:08:07 UTC (rev 11220)
+++ gnuradio/branches/developers/eb/vrt/vrt/include/vrt/rx_packet_handler.h     
2009-06-17 19:20:57 UTC (rev 11221)
@@ -53,7 +53,7 @@
      */
     virtual bool operator()(const uint32_t *payload,
                            size_t n32_bit_words,
-                           const expanded_header *hdr) = 0;
+                           const expanded_header *hdr);
   };
 
 };  // vrt

Modified: gnuradio/branches/developers/eb/vrt/vrt/lib/rx.cc
===================================================================
--- gnuradio/branches/developers/eb/vrt/vrt/lib/rx.cc   2009-06-17 19:08:07 UTC 
(rev 11220)
+++ gnuradio/branches/developers/eb/vrt/vrt/lib/rx.cc   2009-06-17 19:20:57 UTC 
(rev 11221)
@@ -110,11 +110,11 @@
 
 
   bool
-  rx::rx_packets(rx_packet_handler *handler)
+  rx::rx_packets(rx_packet_handler *handler, bool dont_wait)
   {
     vrt_data_handler h(handler);
-    socket_rx_buffer::result r = d_srb->rx_frames(&h, -1);
-    return r == socket_rx_buffer::EB_OK;
+    socket_rx_buffer::result r = d_srb->rx_frames(&h, dont_wait ? 0 : -1);
+    return r == socket_rx_buffer::EB_OK || r == 
socket_rx_buffer::EB_WOULD_BLOCK;
   }
 
 }; // vrt

Modified: gnuradio/branches/developers/eb/vrt/vrt/lib/rx_packet_handler.cc
===================================================================
--- gnuradio/branches/developers/eb/vrt/vrt/lib/rx_packet_handler.cc    
2009-06-17 19:08:07 UTC (rev 11220)
+++ gnuradio/branches/developers/eb/vrt/vrt/lib/rx_packet_handler.cc    
2009-06-17 19:20:57 UTC (rev 11221)
@@ -28,4 +28,14 @@
 
   rx_packet_handler::~rx_packet_handler(){}
 
+  // default operator is a NOP
+  bool 
+  rx_packet_handler::operator()(const uint32_t *payload,
+                               size_t n32_bit_words,
+                               const expanded_header *hdr)
+  {
+    return true;
+  }
+
+
 }; // vrt





reply via email to

[Prev in Thread] Current Thread [Next in Thread]