aboutsummaryrefslogtreecommitdiffstats
path: root/host/examples
diff options
context:
space:
mode:
authorAlex Williams <alex.williams@ni.com>2019-10-01 11:42:24 -0700
committerBrent Stapleton <brent.stapleton@ettus.com>2019-10-07 14:00:48 -0700
commit12a0656c65b956024be7a12ab3cde421d2fb43e4 (patch)
treef88f20460be5c7059405ad5b01347b8f4be73c7d /host/examples
parentf353db8fdd16b31356e118fab994cadaf9c83acc (diff)
downloaduhd-12a0656c65b956024be7a12ab3cde421d2fb43e4.tar.gz
uhd-12a0656c65b956024be7a12ab3cde421d2fb43e4.tar.bz2
uhd-12a0656c65b956024be7a12ab3cde421d2fb43e4.zip
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.
Diffstat (limited to 'host/examples')
-rw-r--r--host/examples/latency_test.cpp19
1 files changed, 16 insertions, 3 deletions
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<size_t>(&nruns)->default_value(1000), "number of tests to perform")
("rtt", po::value<double>(&rtt)->default_value(0.001), "delay between receive and transmit (seconds)")
("rate", po::value<double>(&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<std::complex<float>> 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;
}