commit-gnuradio
[Top][All Lists]
Advanced

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

[Commit-gnuradio] [gnuradio] 02/12: gr-uhd: add parameter to enable/disa


From: git
Subject: [Commit-gnuradio] [gnuradio] 02/12: gr-uhd: add parameter to enable/disable streaming when flowgraph starts
Date: Tue, 29 Dec 2015 22:49:22 +0000 (UTC)

This is an automated email from the git hooks/post-receive script.

jcorgan pushed a commit to branch master
in repository gnuradio.

commit 338cfae6ded4cfae8faa2a089f2c4cce63d47c47
Author: Johannes Schmitz <address@hidden>
Date:   Wed Dec 16 11:31:16 2015 +0100

    gr-uhd: add parameter to enable/disable streaming when flowgraph starts
---
 gr-uhd/include/gnuradio/uhd/usrp_source.h |  5 ++++-
 gr-uhd/lib/usrp_source_impl.cc            | 35 ++++++++++++++++++-------------
 gr-uhd/lib/usrp_source_impl.h             |  4 +++-
 3 files changed, 27 insertions(+), 17 deletions(-)

diff --git a/gr-uhd/include/gnuradio/uhd/usrp_source.h 
b/gr-uhd/include/gnuradio/uhd/usrp_source.h
index 19b3feb..19201c0 100644
--- a/gr-uhd/include/gnuradio/uhd/usrp_source.h
+++ b/gr-uhd/include/gnuradio/uhd/usrp_source.h
@@ -96,10 +96,13 @@ namespace gr {
       /*!
        * \param device_addr the address to identify the hardware
        * \param stream_args the IO format and channel specification
+       * \param issue_stream_cmd_on_start enable or disable continuous 
streaming when flowgraph
+       *   starts (default true)
        * \return a new USRP source block object
        */
       static sptr make(const ::uhd::device_addr_t &device_addr,
-                       const ::uhd::stream_args_t &stream_args);
+                       const ::uhd::stream_args_t &stream_args,
+                       const bool issue_stream_cmd_on_start = true);
 
       /*!
        * Set the start time for incoming samples.
diff --git a/gr-uhd/lib/usrp_source_impl.cc b/gr-uhd/lib/usrp_source_impl.cc
index eeb9521..7ad2280 100644
--- a/gr-uhd/lib/usrp_source_impl.cc
+++ b/gr-uhd/lib/usrp_source_impl.cc
@@ -53,20 +53,23 @@ namespace gr {
 
     usrp_source::sptr
     usrp_source::make(const ::uhd::device_addr_t &device_addr,
-                      const ::uhd::stream_args_t &stream_args)
+                      const ::uhd::stream_args_t &stream_args,
+                      const bool issue_stream_cmd_on_start)
     {
       check_abi();
       return usrp_source::sptr
-        (new usrp_source_impl(device_addr, stream_args_ensure(stream_args)));
+        (new usrp_source_impl(device_addr, stream_args_ensure(stream_args), 
issue_stream_cmd_on_start));
     }
 
     usrp_source_impl::usrp_source_impl(const ::uhd::device_addr_t &device_addr,
-                                       const ::uhd::stream_args_t 
&stream_args):
+                                       const ::uhd::stream_args_t &stream_args,
+                                       const bool issue_stream_cmd_on_start):
       usrp_block("gr uhd usrp source",
                     io_signature::make(0, 0, 0),
                     args_to_io_sig(stream_args)),
       usrp_block_impl(device_addr, stream_args, ""),
-      _tag_now(false)
+      _tag_now(false),
+      _issue_stream_cmd_on_start(issue_stream_cmd_on_start)
     {
       std::stringstream str;
       str << name() << unique_id();
@@ -382,18 +385,20 @@ namespace gr {
         _samps_per_packet = _rx_stream->get_max_num_samps();
       }
 #endif
-      //setup a stream command that starts streaming slightly in the future
-      static const double reasonable_delay = 0.1; //order of magnitude over RTT
-      ::uhd::stream_cmd_t 
stream_cmd(::uhd::stream_cmd_t::STREAM_MODE_START_CONTINUOUS);
-      stream_cmd.stream_now = _stream_now;
-      if(_start_time_set) {
-        _start_time_set = false; //cleared for next run
-        stream_cmd.time_spec = _start_time;
-      }
-      else {
-        stream_cmd.time_spec = get_time_now() + 
::uhd::time_spec_t(reasonable_delay);
+      if(_issue_stream_cmd_on_start){
+        //setup a stream command that starts streaming slightly in the future
+        static const double reasonable_delay = 0.1; //order of magnitude over 
RTT
+        ::uhd::stream_cmd_t 
stream_cmd(::uhd::stream_cmd_t::STREAM_MODE_START_CONTINUOUS);
+        stream_cmd.stream_now = _stream_now;
+        if(_start_time_set) {
+          _start_time_set = false; //cleared for next run
+          stream_cmd.time_spec = _start_time;
+        }
+        else {
+          stream_cmd.time_spec = get_time_now() + 
::uhd::time_spec_t(reasonable_delay);
+        }
+        this->issue_stream_cmd(stream_cmd);
       }
-      this->issue_stream_cmd(stream_cmd);
       _tag_now = true;
       return true;
     }
diff --git a/gr-uhd/lib/usrp_source_impl.h b/gr-uhd/lib/usrp_source_impl.h
index 98af816..b43df4d 100644
--- a/gr-uhd/lib/usrp_source_impl.h
+++ b/gr-uhd/lib/usrp_source_impl.h
@@ -55,7 +55,8 @@ namespace gr {
     {
     public:
       usrp_source_impl(const ::uhd::device_addr_t &device_addr,
-                       const ::uhd::stream_args_t &stream_args);
+                       const ::uhd::stream_args_t &stream_args,
+                       const bool issue_stream_cmd_on_start = true);
       ~usrp_source_impl();
 
       // Get Commands
@@ -119,6 +120,7 @@ namespace gr {
       bool _tag_now;
       ::uhd::rx_metadata_t _metadata;
       pmt::pmt_t _id;
+      bool _issue_stream_cmd_on_start;
 
       //tag shadows
       double _samp_rate;



reply via email to

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