diff options
Diffstat (limited to 'gr-uhd')
-rw-r--r-- | gr-uhd/lib/uhd_mimo_sink.cc | 25 | ||||
-rw-r--r-- | gr-uhd/lib/uhd_mimo_source.cc | 24 |
2 files changed, 22 insertions, 27 deletions
diff --git a/gr-uhd/lib/uhd_mimo_sink.cc b/gr-uhd/lib/uhd_mimo_sink.cc index 6d603d7bc..43ec04164 100644 --- a/gr-uhd/lib/uhd_mimo_sink.cc +++ b/gr-uhd/lib/uhd_mimo_sink.cc @@ -44,7 +44,9 @@ public: const uhd::io_type_t &type ) : uhd_mimo_sink(gr_make_io_signature(num_channels, num_channels, type.size)), _type(type) { + _first_run = false; _dev = uhd::usrp::mimo_usrp::make(args); + _dev->set_time_unknown_pps(uhd::time_spec_t()); //TODO may want option to disable this } ~uhd_mimo_sink_impl(void){ @@ -112,18 +114,31 @@ public: gr_vector_const_void_star &input_items, gr_vector_void_star &output_items ){ - uhd::tx_metadata_t metadata; - metadata.start_of_burst = true; - - return _dev->get_device()->send( - input_items, noutput_items, metadata, + //init the metadata on the first call to work + //and set the timespec with the current time + some offset + if (not _first_run){ + _first_run = true; + _metadata.start_of_burst = true; + _metadata.has_time_spec = true; + _metadata.time_spec = get_time_now() + uhd::time_spec_t(0, 0.01); //10ms offset in future + } + + //call to send with metadata slightly in the future (send-at) + size_t num_sent = _dev->get_device()->send( + input_items, noutput_items, _metadata, _type, uhd::device::SEND_MODE_FULL_BUFF ); + + //increment the send-at time by the number of samples sent + _metadata.time_spec += uhd::time_spec_t(0, num_sent, get_samp_rate_all()); + return num_sent; } protected: uhd::usrp::mimo_usrp::sptr _dev; const uhd::io_type_t _type; + uhd::tx_metadata_t _metadata; + bool _first_run; }; /*********************************************************************** diff --git a/gr-uhd/lib/uhd_mimo_source.cc b/gr-uhd/lib/uhd_mimo_source.cc index fb811572b..28bd1e109 100644 --- a/gr-uhd/lib/uhd_mimo_source.cc +++ b/gr-uhd/lib/uhd_mimo_source.cc @@ -46,7 +46,7 @@ public: { _dev = uhd::usrp::mimo_usrp::make(args); set_streaming(false); - sync_times(); //TODO may want option to disable this + _dev->set_time_unknown_pps(uhd::time_spec_t()); //TODO may want option to disable this } ~uhd_mimo_source_impl(void){ @@ -131,32 +131,12 @@ protected: const uhd::io_type_t _type; bool _is_streaming; - void sync_times(void){ - //set the times to zero at the next pps and sleep (race condition) - set_time_next_pps(uhd::time_spec_t(0, 0)); sleep(1); - - //catch the seconds rollover at the next pps - double last_frac_secs = 0.0, curr_frac_secs = 0.0; - while(curr_frac_secs > last_frac_secs){ - last_frac_secs = curr_frac_secs; - curr_frac_secs = get_time_now().get_frac_secs(); - } - - //set the times to zero at the next pps and sleep (all boards synced) - set_time_next_pps(uhd::time_spec_t(0, 0)); sleep(1); - } - void set_streaming(bool enb){ if (enb){ - //make an estimate of the trip time - uhd::time_spec_t time1 = get_time_now(); - uhd::time_spec_t time2 = get_time_now(); - double rtt = 2*(time2 - time1).get_real_secs(); - //setup a stream command that starts streaming slightly in the future uhd::stream_cmd_t stream_cmd(uhd::stream_cmd_t::STREAM_MODE_START_CONTINUOUS); stream_cmd.stream_now = false; - stream_cmd.time_spec = time2 + uhd::time_spec_t(0, (_dev->get_num_channels()+1)*rtt); + stream_cmd.time_spec = get_time_now() + uhd::time_spec_t(0, 0.01); //10ms offset in future _dev->issue_stream_cmd(stream_cmd); } else |