From 1c185f8478955c170ba6cf429826dfb286c3c045 Mon Sep 17 00:00:00 2001 From: Martin Braun Date: Mon, 13 Jul 2015 16:53:35 -0700 Subject: examples: Improved tx_waveform multi-channel sync --- host/examples/tx_waveforms.cpp | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) (limited to 'host/examples') diff --git a/host/examples/tx_waveforms.cpp b/host/examples/tx_waveforms.cpp index 7e633262c..d648d2309 100644 --- a/host/examples/tx_waveforms.cpp +++ b/host/examples/tx_waveforms.cpp @@ -225,15 +225,17 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ std::vector > buff(spb); std::vector *> buffs(channel_nums.size(), &buff.front()); - //setup the metadata flags - uhd::tx_metadata_t md; - md.start_of_burst = true; - md.end_of_burst = false; - md.has_time_spec = true; - md.time_spec = uhd::time_spec_t(0.1); - std::cout << boost::format("Setting device timestamp to 0...") << std::endl; - usrp->set_time_now(uhd::time_spec_t(0.0)); + if (channel_nums.size() > 1) { + // This is the worst-case setup scenario, because this example has to + // work for all configurations. set_time_now() and set_time_next_pps() + // might also work, depending on what USRPs are being used, and can + // accelerate the setup. To keep this example generic, we use + // set_time_unknown_pps() to guarantee synchronization. + usrp->set_time_unknown_pps(uhd::time_spec_t(0.0)); + } else { + usrp->set_time_now(uhd::time_spec_t(0.0)); + } //Check Ref and LO Lock detect std::vector sensor_names; @@ -258,6 +260,14 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ std::signal(SIGINT, &sig_int_handler); std::cout << "Press Ctrl + C to stop streaming..." << std::endl; + // Set up metadata. We start streaming a bit in the future + // to allow MIMO operation: + uhd::tx_metadata_t md; + md.start_of_burst = true; + md.end_of_burst = false; + md.has_time_spec = true; + md.time_spec = usrp->get_time_now() + uhd::time_spec_t(0.1); + //send data until the signal handler gets called while(not stop_signal_called){ //fill the buffer with the waveform -- cgit v1.2.3