diff options
Diffstat (limited to 'gr-uhd')
-rw-r--r-- | gr-uhd/lib/uhd_simple_sink.cc | 8 | ||||
-rw-r--r-- | gr-uhd/lib/uhd_simple_source.cc | 21 | ||||
-rw-r--r-- | gr-uhd/lib/uhd_simple_source.h | 1 | ||||
-rw-r--r-- | gr-uhd/lib/utils.cc | 4 |
4 files changed, 20 insertions, 14 deletions
diff --git a/gr-uhd/lib/uhd_simple_sink.cc b/gr-uhd/lib/uhd_simple_sink.cc index 269487f0e..01581bb76 100644 --- a/gr-uhd/lib/uhd_simple_sink.cc +++ b/gr-uhd/lib/uhd_simple_sink.cc @@ -66,18 +66,16 @@ int uhd_simple_sink::work( gr_vector_const_void_star &input_items, gr_vector_void_star &output_items ){ - - const size_t max_samples = wax::cast<size_t>((*_dev)[uhd::DEVICE_PROP_MAX_TX_SAMPLES]); size_t total_items_sent = 0; - uhd::metadata_t metadata; + uhd::tx_metadata_t metadata; metadata.start_of_burst = true; - //handles fragmentation + //call until the input items are all sent while(total_items_sent < size_t(noutput_items)){ size_t items_sent = _dev->send( boost::asio::buffer( (uint8_t *)input_items[0]+(total_items_sent*_sizeof_samp), - std::min(max_samples, noutput_items-total_items_sent)*_sizeof_samp + (noutput_items-total_items_sent)*_sizeof_samp ), metadata, _type ); total_items_sent += items_sent; diff --git a/gr-uhd/lib/uhd_simple_source.cc b/gr-uhd/lib/uhd_simple_source.cc index f6a783ef9..17691c7ae 100644 --- a/gr-uhd/lib/uhd_simple_source.cc +++ b/gr-uhd/lib/uhd_simple_source.cc @@ -53,7 +53,7 @@ uhd_simple_source::uhd_simple_source( _dev = uhd::device::make(addr); _sizeof_samp = get_size(type); - set_streaming(true); + set_streaming(false); } uhd_simple_source::~uhd_simple_source(void){ @@ -68,6 +68,7 @@ void uhd_simple_source::set_streaming(bool enb){ [uhd::DEVICE_PROP_MBOARD] [uhd::named_prop_t(uhd::MBOARD_PROP_RX_DSP, "ddc0")]; ddc[std::string("enabled")] = enb; + _is_streaming = enb; } /*********************************************************************** @@ -78,12 +79,16 @@ int uhd_simple_source::work( gr_vector_const_void_star &input_items, gr_vector_void_star &output_items ){ - - const size_t max_samples = wax::cast<size_t>((*_dev)[uhd::DEVICE_PROP_MAX_RX_SAMPLES]); + //conditionally start streaming in the work call + //this prevents streaming before the runtime is ready + if (not _is_streaming) set_streaming(true); size_t total_items_read = 0; - size_t count = 50; - uhd::metadata_t metadata; + size_t timeout_count = 50; + uhd::rx_metadata_t metadata; + + //call until the output items are all filled + //or an exit condition below is encountered while(total_items_read < size_t(noutput_items)){ size_t items_read = _dev->recv( boost::asio::buffer( @@ -99,11 +104,13 @@ int uhd_simple_source::work( } //if we have read at least once, but not this time, get out - if (total_items_read > 0) break; + // commented out behaviour: I believe that it would be better to + // fill the buffer entirely to mimimize scheduler context switching + //if (total_items_read > 0) break; //the timeout part boost::this_thread::sleep(boost::posix_time::milliseconds(1)); - if (--count == 0) break; + if (--timeout_count == 0) break; } return total_items_read; diff --git a/gr-uhd/lib/uhd_simple_source.h b/gr-uhd/lib/uhd_simple_source.h index 43c4a647a..5d2dafe49 100644 --- a/gr-uhd/lib/uhd_simple_source.h +++ b/gr-uhd/lib/uhd_simple_source.h @@ -44,6 +44,7 @@ public: protected: void set_streaming(bool enb); + bool _is_streaming; //shadow for the streaming status uhd::device::sptr _dev; std::string _type; diff --git a/gr-uhd/lib/utils.cc b/gr-uhd/lib/utils.cc index c92846dc1..e36320c3c 100644 --- a/gr-uhd/lib/utils.cc +++ b/gr-uhd/lib/utils.cc @@ -20,7 +20,7 @@ * Boston, MA 02110-1301, USA. */ -#include "utils.h" +#include "utils.h" //local include #include <boost/algorithm/string.hpp> #include <boost/algorithm/string/trim.hpp> #include <boost/foreach.hpp> @@ -54,7 +54,7 @@ size_t get_size(const std::string &type){ return sizeof(std::complex<float>); } if(type == "16sc"){ - return sizeof(std::complex<short>); + return sizeof(std::complex<int16_t>); } throw std::runtime_error("unknown type"); } |