From 3795a17b08404ff7ce5958afe1585b6b2ba561d7 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Sat, 29 Sep 2012 20:43:40 -0700 Subject: uhd: provide source block hook for issue stream cmd --- gr-uhd/include/gr_uhd_usrp_source.h | 13 +++++++++++++ gr-uhd/lib/gr_uhd_usrp_source.cc | 5 +++++ gr-uhd/swig/uhd_swig.i | 2 ++ 3 files changed, 20 insertions(+) (limited to 'gr-uhd') diff --git a/gr-uhd/include/gr_uhd_usrp_source.h b/gr-uhd/include/gr_uhd_usrp_source.h index b5acabee4..1243ddcc2 100644 --- a/gr-uhd/include/gr_uhd_usrp_source.h +++ b/gr-uhd/include/gr_uhd_usrp_source.h @@ -128,6 +128,19 @@ public: */ virtual void set_start_time(const uhd::time_spec_t &time) = 0; + /*! + * *Advanced use only:* + * Issue a stream command to all channels in this source block. + * + * This method is intended to override the default "always on" behavior. + * After starting the flow graph, the user should call stop() on this block, + * then issue any desired arbitrary stream_cmd_t structs to the device. + * The USRP will be able to enqueue several stream commands in the FPGA. + * + * \param cmd the stream command to issue to all source channels + */ + virtual void issue_stream_cmd(const uhd::stream_cmd_t &cmd) = 0; + /*! * Returns identifying information about this USRP's configuration. * Returns motherboard ID, name, and serial. diff --git a/gr-uhd/lib/gr_uhd_usrp_source.cc b/gr-uhd/lib/gr_uhd_usrp_source.cc index ad4cb4d81..139caf9dd 100644 --- a/gr-uhd/lib/gr_uhd_usrp_source.cc +++ b/gr-uhd/lib/gr_uhd_usrp_source.cc @@ -402,6 +402,11 @@ public: _stream_now = false; } + void issue_stream_cmd(const uhd::stream_cmd_t &cmd) + { + _dev->issue_stream_cmd(cmd); + } + bool start(void){ #ifdef GR_UHD_USE_STREAM_API _rx_stream = _dev->get_rx_stream(_stream_args); diff --git a/gr-uhd/swig/uhd_swig.i b/gr-uhd/swig/uhd_swig.i index 513c1da7e..99258c0f5 100644 --- a/gr-uhd/swig/uhd_swig.i +++ b/gr-uhd/swig/uhd_swig.i @@ -76,6 +76,8 @@ %include +%include + %include %include -- cgit From 692890cd40aa07a8290c7fdee24c94b6a0eabb8c Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Sat, 29 Sep 2012 20:14:51 -0700 Subject: uhd: work does not block, OK to return 0 on ERROR_CODE_TIMEOUT --- gr-uhd/lib/gr_uhd_usrp_source.cc | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'gr-uhd') diff --git a/gr-uhd/lib/gr_uhd_usrp_source.cc b/gr-uhd/lib/gr_uhd_usrp_source.cc index 139caf9dd..3813673b4 100644 --- a/gr-uhd/lib/gr_uhd_usrp_source.cc +++ b/gr-uhd/lib/gr_uhd_usrp_source.cc @@ -338,8 +338,8 @@ public: //If receive resulted in a timeout condition: //We now receive a single packet with a large timeout. - while (_metadata.error_code == uhd::rx_metadata_t::ERROR_CODE_TIMEOUT){ - if (boost::this_thread::interruption_requested()) return WORK_DONE; + if (_metadata.error_code == uhd::rx_metadata_t::ERROR_CODE_TIMEOUT) + { num_samps = _rx_stream->recv( output_items, noutput_items, _metadata, 0.1, true/*one pkt*/ ); @@ -377,9 +377,8 @@ public: break; case uhd::rx_metadata_t::ERROR_CODE_TIMEOUT: - //Assume that the user called stop() on the flow graph. - //However, a timeout can occur under error conditions. - return WORK_DONE; + //its ok to timeout, perhaps the user is doing finite streaming + return 0; case uhd::rx_metadata_t::ERROR_CODE_OVERFLOW: _tag_now = true; -- cgit