diff options
author | michael-west <michael.west@ettus.com> | 2020-10-11 19:45:25 -0700 |
---|---|---|
committer | Aaron Rossetto <aaron.rossetto@ni.com> | 2020-10-12 15:10:07 -0500 |
commit | 0a5e173eba82859e4e5d5c9d19852e8131d5deac (patch) | |
tree | a65c63c6a6ac01d88c96b7aa784691ad58d49f64 /host/examples | |
parent | 86568d46b62bd1ab13dd3479b8fe2ea425271806 (diff) | |
download | uhd-0a5e173eba82859e4e5d5c9d19852e8131d5deac.tar.gz uhd-0a5e173eba82859e4e5d5c9d19852e8131d5deac.tar.bz2 uhd-0a5e173eba82859e4e5d5c9d19852e8131d5deac.zip |
examples: Fix --random option in benchmark_rate
The implementation was not properly configuring the stream command if
the --random flag was used. It was especially bad when multiple
channels were specified.
Signed-off-by: michael-west <michael.west@ettus.com>
Diffstat (limited to 'host/examples')
-rw-r--r-- | host/examples/benchmark_rate.cpp | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/host/examples/benchmark_rate.cpp b/host/examples/benchmark_rate.cpp index 673649ddb..d975c4c0c 100644 --- a/host/examples/benchmark_rate.cpp +++ b/host/examples/benchmark_rate.cpp @@ -100,6 +100,11 @@ void benchmark_rx_rate(uhd::usrp::multi_usrp::sptr usrp, const double rate = usrp->get_rx_rate(); uhd::stream_cmd_t cmd(uhd::stream_cmd_t::STREAM_MODE_START_CONTINUOUS); + cmd.num_samps = max_samps_per_packet; + if (random_nsamps) { + cmd.stream_mode = uhd::stream_cmd_t::STREAM_MODE_NUM_SAMPS_AND_DONE; + cmd.num_samps = (rand() % max_samps_per_packet) + 1; + } cmd.time_spec = usrp->get_time_now() + uhd::time_spec_t(rx_delay); cmd.stream_now = (buffs.size() == 1); rx_stream->issue_stream_cmd(cmd); @@ -115,11 +120,12 @@ void benchmark_rx_rate(uhd::usrp::multi_usrp::sptr usrp, stop_called = true; } if (random_nsamps) { - cmd.num_samps = rand() % max_samps_per_packet; + cmd.time_spec = usrp->get_time_now() + uhd::time_spec_t(rx_delay); + cmd.num_samps = (rand() % max_samps_per_packet) + 1; rx_stream->issue_stream_cmd(cmd); } try { - num_rx_samps += rx_stream->recv(buffs, max_samps_per_packet, md, recv_timeout) + num_rx_samps += rx_stream->recv(buffs, cmd.num_samps, md, recv_timeout) * rx_stream->get_num_channels(); recv_timeout = burst_pkt_time; } catch (uhd::io_error& e) { @@ -236,17 +242,17 @@ void benchmark_tx_rate(uhd::usrp::multi_usrp::sptr usrp, if (random_nsamps) { std::srand((unsigned int)time(NULL)); while (not burst_timer_elapsed) { - size_t total_num_samps = rand() % max_samps_per_packet; + size_t total_num_samps = (rand() % max_samps_per_packet) + 1; size_t num_acc_samps = 0; - usrp->set_time_now(uhd::time_spec_t(0.0)); while (num_acc_samps < total_num_samps) { // send a single packet num_tx_samps += tx_stream->send(buffs, spp, md, timeout) * tx_stream->get_num_channels(); num_acc_samps += std::min( - total_num_samps - num_acc_samps, tx_stream->get_max_num_samps()); + total_num_samps - num_acc_samps, max_samps_per_packet); } + md.has_time_spec = false; } } else { while (not burst_timer_elapsed) { |