diff options
author | Michael West <michael.west@ettus.com> | 2014-01-15 15:09:58 -0800 |
---|---|---|
committer | Michael West <michael.west@ettus.com> | 2014-01-15 15:09:58 -0800 |
commit | dd8e4999794e298505a303abb59d3a0a1824238e (patch) | |
tree | 21b6c258b7dc7c0e4cb098cb13dbdc55f2abba27 /host/examples | |
parent | 61c5ddbe9cc391da5e70bd90bae8b9b2dcab280a (diff) | |
download | uhd-dd8e4999794e298505a303abb59d3a0a1824238e.tar.gz uhd-dd8e4999794e298505a303abb59d3a0a1824238e.tar.bz2 uhd-dd8e4999794e298505a303abb59d3a0a1824238e.zip |
Added timed control commands to test_timed_commands example. Added radio core as subscriber to tick rate change for B200.
Diffstat (limited to 'host/examples')
-rw-r--r-- | host/examples/test_timed_commands.cpp | 41 |
1 files changed, 35 insertions, 6 deletions
diff --git a/host/examples/test_timed_commands.cpp b/host/examples/test_timed_commands.cpp index 10336ec34..8c6011c68 100644 --- a/host/examples/test_timed_commands.cpp +++ b/host/examples/test_timed_commands.cpp @@ -78,9 +78,40 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ total_time += (t1-t0); } std::cout << boost::format( - "Difference between paired reads: %f us" + " Difference between paired reads: %f us" ) % (total_time.get_real_secs()/100*1e6) << std::endl; + //test timed control command + //issues get_time_now() command twice a fixed time apart + //outputs difference for each response time vs. the expected time + //and difference between actual and expected time deltas + std::cout << std::endl; + std::cout << "Testing control timed command:" << std::endl; + const uhd::time_spec_t span = uhd::time_spec_t(0.1); + const uhd::time_spec_t now = usrp->get_time_now(); + const uhd::time_spec_t cmd_time1 = now + uhd::time_spec_t(0.1); + const uhd::time_spec_t cmd_time2 = cmd_time1 + span; + usrp->set_command_time(cmd_time1); + uhd::time_spec_t response_time1 = usrp->get_time_now(); + usrp->set_command_time(cmd_time2); + uhd::time_spec_t response_time2 = usrp->get_time_now(); + usrp->clear_command_time(); + std::cout << boost::format( + " Span : %f us\n" + " Now : %f us\n" + " Response 1: %f us\n" + " Response 2: %f us" + ) % (span.get_real_secs()*1e6) % (now.get_real_secs()*1e6) % (response_time1.get_real_secs()*1e6) % (response_time2.get_real_secs()*1e6) << std::endl; + std::cout << boost::format( + " Difference of response time 1: %f us" + ) % ((response_time1 - cmd_time1).get_real_secs()*1e6) << std::endl; + std::cout << boost::format( + " Difference of response time 2: %f us" + ) % ((response_time2 - cmd_time2).get_real_secs()*1e6) << std::endl; + std::cout << boost::format( + " Difference between actual and expected time delta: %f us" + ) % ((response_time2 - response_time1 - span).get_real_secs()*1e6) << std::endl; + //use a timed command to start a stream at a specific time //this is not the right way start streaming at time x, //but it should approximate it within control RTT/2 @@ -96,10 +127,8 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ stream_cmd.num_samps = 100; stream_cmd.stream_now = false; const uhd::time_spec_t stream_time = usrp->get_time_now() + uhd::time_spec_t(0.1); - usrp->set_command_time(stream_time); stream_cmd.time_spec = stream_time; rx_stream->issue_stream_cmd(stream_cmd); - usrp->clear_command_time(); //meta-data will be filled in by recv() uhd::rx_metadata_t md; @@ -114,13 +143,13 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ ) % md.error_code)); } std::cout << boost::format( - "Received packet: %u samples, %u full secs, %f frac secs" + " Received packet: %u samples, %u full secs, %f frac secs" ) % num_rx_samps % md.time_spec.get_full_secs() % md.time_spec.get_frac_secs() << std::endl; std::cout << boost::format( - "Stream time was: %u full secs, %f frac secs" + " Stream time was: %u full secs, %f frac secs" ) % stream_time.get_full_secs() % stream_time.get_frac_secs() << std::endl; std::cout << boost::format( - "Difference between stream time and first packet: %f us" + " Difference between stream time and first packet: %f us" ) % ((md.time_spec-stream_time).get_real_secs()*1e6) << std::endl; //finished |