aboutsummaryrefslogtreecommitdiffstats
path: root/host/utils/uhd_cal_rx_iq_balance.cpp
diff options
context:
space:
mode:
authormichael-west <michael.west@ettus.com>2021-04-15 23:51:25 -0700
committerAaron Rossetto <aaron.rossetto@ni.com>2021-04-29 15:12:05 -0500
commit1488781b091484d52e7c9b96115b0ab5a9b3e957 (patch)
treed34089ad092c8bed572757d9edccd5183fe57549 /host/utils/uhd_cal_rx_iq_balance.cpp
parentd689df23fb4bf38e1abc23b06767fc26aa27c163 (diff)
downloaduhd-1488781b091484d52e7c9b96115b0ab5a9b3e957.tar.gz
uhd-1488781b091484d52e7c9b96115b0ab5a9b3e957.tar.bz2
uhd-1488781b091484d52e7c9b96115b0ab5a9b3e957.zip
utils: Improve cal TX threads
Increase thread priority on TX thread and remove memory copy to reduce underruns. Signed-off-by: michael-west <michael.west@ettus.com>
Diffstat (limited to 'host/utils/uhd_cal_rx_iq_balance.cpp')
-rw-r--r--host/utils/uhd_cal_rx_iq_balance.cpp43
1 files changed, 6 insertions, 37 deletions
diff --git a/host/utils/uhd_cal_rx_iq_balance.cpp b/host/utils/uhd_cal_rx_iq_balance.cpp
index ff074acef..8b9ada1a4 100644
--- a/host/utils/uhd_cal_rx_iq_balance.cpp
+++ b/host/utils/uhd_cal_rx_iq_balance.cpp
@@ -10,11 +10,8 @@
#include <uhd/utils/algorithm.hpp>
#include <uhd/utils/paths.hpp>
#include <uhd/utils/safe_main.hpp>
-#include <uhd/utils/thread.hpp>
#include <boost/format.hpp>
-#include <boost/math/special_functions/round.hpp>
#include <boost/program_options.hpp>
-#include <boost/thread/thread.hpp>
#include <chrono>
#include <cmath>
#include <complex>
@@ -22,38 +19,10 @@
#include <ctime>
#include <functional>
#include <iostream>
-#include <thread>
namespace po = boost::program_options;
/***********************************************************************
- * Transmit thread
- **********************************************************************/
-static void tx_thread(uhd::usrp::multi_usrp::sptr usrp,
- uhd::tx_streamer::sptr tx_stream,
- const double tx_wave_ampl)
-{
- // set max TX gain
- usrp->set_tx_gain(usrp->get_tx_gain_range().stop());
-
- // setup variables and allocate buffer
- uhd::tx_metadata_t md;
- md.has_time_spec = false;
- std::vector<samp_type> buff(tx_stream->get_max_num_samps() * 10);
-
- // fill buff and send until interrupted
- while (not boost::this_thread::interruption_requested()) {
- for (size_t i = 0; i < buff.size(); i++)
- buff[i] = float(tx_wave_ampl);
- tx_stream->send(&buff.front(), buff.size(), md);
- }
-
- // send a mini EOB packet
- md.end_of_burst = true;
- tx_stream->send("", 0, md);
-}
-
-/***********************************************************************
* Tune RX and TX routine
**********************************************************************/
static double tune_rx_and_tx(
@@ -142,8 +111,10 @@ int UHD_SAFE_MAIN(int argc, char* argv[])
uhd::tx_streamer::sptr tx_stream = usrp->get_tx_stream(stream_args);
// create a transmitter thread
- boost::thread_group threads;
- threads.create_thread(std::bind(&tx_thread, usrp, tx_stream, tx_wave_ampl));
+ std::atomic_flag transmit = ATOMIC_FLAG_INIT;
+ transmit.test_and_set();
+ auto transmitter =
+ std::thread(std::bind(&tx_thread, &transmit, usrp, tx_stream, 0.0, tx_wave_ampl));
// re-usable buffer for samples
std::vector<samp_type> buff;
@@ -292,10 +263,8 @@ int UHD_SAFE_MAIN(int argc, char* argv[])
std::cout << std::endl;
// stop the transmitter
- threads.interrupt_all();
- std::this_thread::sleep_for(
- std::chrono::milliseconds(500)); // wait for threads to finish
- threads.join_all();
+ transmit.clear();
+ transmitter.join();
store_results(results, "RX", "rx", "iq", serial);