From a751e4884d918c079d07d3108f5561ac43c3553e Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Mon, 19 Mar 2012 10:34:48 -0700 Subject: uhd: added set_start_time calls to source/sink --- gr-uhd/lib/gr_uhd_usrp_sink.cc | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) (limited to 'gr-uhd/lib/gr_uhd_usrp_sink.cc') diff --git a/gr-uhd/lib/gr_uhd_usrp_sink.cc b/gr-uhd/lib/gr_uhd_usrp_sink.cc index 05237100c..5d8d235a1 100644 --- a/gr-uhd/lib/gr_uhd_usrp_sink.cc +++ b/gr-uhd/lib/gr_uhd_usrp_sink.cc @@ -56,7 +56,9 @@ public: gr_make_io_signature(0, 0, 0) ), _stream_args(stream_args), - _nchan(std::max(1, stream_args.channels.size())) + _nchan(std::max(1, stream_args.channels.size())), + _stream_now(_nchan == 1), + _start_time_set(false) { if (stream_args.cpu_format == "fc32") _type = boost::make_shared(uhd::io_type_t::COMPLEX_FLOAT32); if (stream_args.cpu_format == "sc16") _type = boost::make_shared(uhd::io_type_t::COMPLEX_INT16); @@ -372,6 +374,12 @@ public: } } + void set_start_time(const uhd::time_spec_t &time){ + _start_time = time; + _start_time_set = true; + _stream_now = false; + } + //Send an empty start-of-burst packet to begin streaming. //Set at a time in the near future to avoid late packets. bool start(void){ @@ -381,8 +389,14 @@ public: _metadata.start_of_burst = true; _metadata.end_of_burst = false; - _metadata.has_time_spec = _nchan > 1; - _metadata.time_spec = get_time_now() + uhd::time_spec_t(0.01); + _metadata.has_time_spec = not _stream_now; + if (_start_time_set){ + _start_time_set = false; //cleared for next run + _metadata.time_spec = _start_time; + } + else{ + _metadata.time_spec = get_time_now() + uhd::time_spec_t(0.01); + } #ifdef GR_UHD_USE_STREAM_API _tx_stream->send( @@ -423,9 +437,13 @@ private: uhd::tx_streamer::sptr _tx_stream; #endif size_t _nchan; + bool _stream_now; uhd::tx_metadata_t _metadata; double _sample_rate; + uhd::time_spec_t _start_time; + bool _start_time_set; + //stream tags related stuff std::vector _tags; }; -- cgit From 90213d65782dbbc612494ed28568e23b42961488 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Thu, 22 Mar 2012 15:30:56 -0700 Subject: uhd: perform abi compat check before making a block --- gr-uhd/lib/gr_uhd_usrp_sink.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'gr-uhd/lib/gr_uhd_usrp_sink.cc') diff --git a/gr-uhd/lib/gr_uhd_usrp_sink.cc b/gr-uhd/lib/gr_uhd_usrp_sink.cc index 5d8d235a1..ab5c771c7 100644 --- a/gr-uhd/lib/gr_uhd_usrp_sink.cc +++ b/gr-uhd/lib/gr_uhd_usrp_sink.cc @@ -1,5 +1,5 @@ /* - * Copyright 2010-2011 Free Software Foundation, Inc. + * Copyright 2010-2012 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -23,6 +23,7 @@ #include #include #include +#include "gr_uhd_common.h" static const pmt::pmt_t SOB_KEY = pmt::pmt_string_to_symbol("tx_sob"); static const pmt::pmt_t EOB_KEY = pmt::pmt_string_to_symbol("tx_eob"); @@ -474,6 +475,7 @@ boost::shared_ptr uhd_make_usrp_sink( const uhd::device_addr_t &device_addr, const uhd::stream_args_t &stream_args ){ + gr_uhd_check_abi(); return boost::shared_ptr( new uhd_usrp_sink_impl(device_addr, stream_args) ); -- cgit