]> git.gag.com Git - debian/gnuradio/commitdiff
gr-usrp2: implement start_streaming_at(usrp2::fpga_timestamp time)
authorJohnathan Corgan <jcorgan@corganenterprises.com>
Sat, 19 Jun 2010 18:27:56 +0000 (11:27 -0700)
committerJohnathan Corgan <jcorgan@corganenterprises.com>
Sat, 19 Jun 2010 18:27:56 +0000 (11:27 -0700)
This new method on usrp2.sink_* causes the first TX sample data to be
sent at the FPGA clock time specified, with all further data immediately
following.

u = usrp2.sink_32fc() # or 16sc
...configure sink here...
u.sync_to_pps()
...delay a second for PPS to have happened
u.start_streaming_at(int(100e6)) # start TX stream one second later
...start flowgraph here...

If this function is not called, all transmit data will be sent
immediately (the prior behavior).

gr-usrp2/src/usrp2.i
gr-usrp2/src/usrp2_sink_16sc.cc
gr-usrp2/src/usrp2_sink_32fc.cc
gr-usrp2/src/usrp2_sink_base.cc
gr-usrp2/src/usrp2_sink_base.h

index d1fa091f73f6d8c69e5409dfe688899be207683e..2a79fad44b8f5831a4dee3e96b97b2740254000b 100644 (file)
@@ -32,6 +32,7 @@
 
 %include <usrp2/tune_result.h>
 %include <usrp2/mimo_config.h>
+%include <usrp2/metadata.h>
 
 %template(uint32_t_vector) std::vector<uint32_t>;
 
@@ -163,6 +164,7 @@ public:
   bool write_gpio(uint16_t value, uint16_t mask);
   %rename(_real_read_gpio) read_gpio;
   bool read_gpio(uint16_t *value);
+  bool start_streaming_at(usrp2::fpga_timestamp time);
 };
 
 // ----------------------------------------------------------------
index 1e7c54dcdb16d8c0cb62f0281c39af9303b0c3bf..75cc1f4a6bebb5857ce4fe1ee9df03f2f8680c5c 100644 (file)
@@ -67,12 +67,20 @@ usrp2_sink_16sc::work(int noutput_items,
     return 0;
 
   usrp2::tx_metadata metadata;
-  metadata.timestamp = -1;
-  metadata.send_now = 1;
+
+  // Set TX metadata to either start time or now
+  if (d_should_wait == true) {
+    metadata.timestamp = d_tx_time;
+    metadata.send_now = 0;
+    d_should_wait = false;
+  }
+  else {
+    metadata.timestamp = -1;
+    metadata.send_now = 1;
+  }
   metadata.start_of_burst = 1;
 
-  bool ok = d_u2->tx_16sc(0,  // FIXME: someday, streams will have channel numbers
-                         in, noutput_items, &metadata);
+  bool ok = d_u2->tx_16sc(0, in, noutput_items, &metadata);
   if (!ok){
     std::cerr << "usrp2_sink_16sc: tx_16sc failed" << std::endl;
     return -1; // say we're done
index b1e28a8297ee83468801a8ebd57a43e916d86938..fa75b380571dc960fe4ea56449917f2d5c295362 100644 (file)
@@ -67,12 +67,20 @@ usrp2_sink_32fc::work(int noutput_items,
     return 0;
 
   usrp2::tx_metadata metadata;
-  metadata.timestamp = -1;
-  metadata.send_now = 1;
+
+  // Set TX metadata to either start time or now
+  if (d_should_wait == true) {
+    metadata.timestamp = d_tx_time;
+    metadata.send_now = 0;
+    d_should_wait = false;
+  }
+  else {
+    metadata.timestamp = -1;
+    metadata.send_now = 1;
+  }
   metadata.start_of_burst = 1;
 
-  bool ok = d_u2->tx_32fc(0, // FIXME: someday, streams will have channel numbers
-                         in, noutput_items, &metadata);
+  bool ok = d_u2->tx_32fc(0, in, noutput_items, &metadata);
   if (!ok){
     std::cerr << "usrp2_sink_32fc: tx_32fc failed" << std::endl;
     return -1; // say we're done
index ce473f2365e08b132237f219921d6d4b52c6d142..c9b34a54a93669974226ec79abba05bc87f7a132 100644 (file)
@@ -36,7 +36,9 @@ usrp2_sink_base::usrp2_sink_base(const char *name,
   : usrp2_base(name,
                input_signature,
               gr_make_io_signature(0, 0, 0),
-              ifc, mac)
+              ifc, mac),
+    d_should_wait(false),
+    d_tx_time(0)
 {
   // NOP
 }
@@ -155,3 +157,10 @@ bool usrp2_sink_base::read_gpio(uint16_t *value)
 {
   return d_u2->read_gpio(usrp2::GPIO_TX_BANK, value);
 }
+
+bool usrp2_sink_base::start_streaming_at(usrp2::fpga_timestamp time)
+{
+  d_should_wait = true;
+  d_tx_time = time;
+  return true;
+}
index 38dc4f2364a60fef6cbadc39c8394afcca9ed06a..d831d4df6951d4ee2e250e2f1059c610f820262b 100644 (file)
@@ -37,6 +37,9 @@ protected:
                  const std::string &mac)
     throw (std::runtime_error);
 
+  bool d_should_wait;
+  usrp2::fpga_timestamp d_tx_time;
+
 public:
   ~usrp2_sink_base();
 
@@ -139,6 +142,11 @@ public:
    * \brief Read daughterboard GPIO pin values
    */
   bool read_gpio(uint16_t *value);
+
+  /*!
+   * \brief First samples begin streaming to USRP2 at given time
+   */
+  bool start_streaming_at(usrp2::fpga_timestamp time);
 };
 
 #endif /* INCLUDED_USRP2_SINK_BASE_H */