From 12a0656c65b956024be7a12ab3cde421d2fb43e4 Mon Sep 17 00:00:00 2001 From: Alex Williams Date: Tue, 1 Oct 2019 11:42:24 -0700 Subject: examples: Add mode to remove latency of RX samples in latency_test The timestamp from the streamer corresponds to the first sample, but a better indicator of transport latency will use the time of the last RX sample. Otherwise, nsamps will reduce the timing budget to send the TX samples. Include this mode to allow latency_test to have a version where there is largely no dependence amongst the variables. --- host/examples/latency_test.cpp | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'host/examples') diff --git a/host/examples/latency_test.cpp b/host/examples/latency_test.cpp index 798279310..69d34dbff 100644 --- a/host/examples/latency_test.cpp +++ b/host/examples/latency_test.cpp @@ -36,6 +36,7 @@ int UHD_SAFE_MAIN(int argc, char* argv[]) ("nruns", po::value(&nruns)->default_value(1000), "number of tests to perform") ("rtt", po::value(&rtt)->default_value(0.001), "delay between receive and transmit (seconds)") ("rate", po::value(&rate)->default_value(100e6/4), "sample rate for receive and transmit (sps)") + ("from-eob", "specify to define rtt to not include the time to clock out the RX samples (removes dependence on nsamps and rate)") ("verbose", "specify to enable inner-loop verbose") ; // clang-format on @@ -61,7 +62,8 @@ int UHD_SAFE_MAIN(int argc, char* argv[]) return EXIT_SUCCESS; } - bool verbose = vm.count("verbose") != 0; + bool verbose = vm.count("verbose") != 0; + bool from_eob = vm.count("from-eob") != 0; // create a usrp device std::cout << std::endl; @@ -80,9 +82,17 @@ int UHD_SAFE_MAIN(int argc, char* argv[]) // set the rx sample rate usrp->set_rx_rate(rate); - std::cout << boost::format("Actual RX Rate: %f Msps...") % (usrp->get_rx_rate() / 1e6) + double actual_rx_rate = usrp->get_rx_rate(); + std::cout << boost::format("Actual RX Rate: %f Msps...") % (actual_rx_rate / 1e6) << std::endl; + double rx_time = nsamps / actual_rx_rate; + if (from_eob) { + std::cout << boost::format("Will add %f seconds to timespec for RX samples...") + % (rx_time) + << std::endl; + } + // allocate a buffer to use std::vector> buffer(nsamps); @@ -131,7 +141,10 @@ int UHD_SAFE_MAIN(int argc, char* argv[]) tx_md.end_of_burst = true; tx_md.has_time_spec = true; tx_md.time_spec = rx_md.time_spec + uhd::time_spec_t(rtt); - size_t num_tx_samps = tx_stream->send(&buffer.front(), buffer.size(), tx_md); + if (from_eob) { + tx_md.time_spec += uhd::time_spec_t(rx_time); + } + size_t num_tx_samps = tx_stream->send(&buffer.front(), buffer.size(), tx_md); if (verbose) { std::cout << boost::format("Sent %d samples") % num_tx_samps << std::endl; } -- cgit v1.2.3