aboutsummaryrefslogtreecommitdiffstats
path: root/host/utils/uhd_cal_tx_iq_balance.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'host/utils/uhd_cal_tx_iq_balance.cpp')
-rw-r--r--host/utils/uhd_cal_tx_iq_balance.cpp50
1 files changed, 6 insertions, 44 deletions
diff --git a/host/utils/uhd_cal_tx_iq_balance.cpp b/host/utils/uhd_cal_tx_iq_balance.cpp
index 5f2695784..5c9f981c9 100644
--- a/host/utils/uhd_cal_tx_iq_balance.cpp
+++ b/host/utils/uhd_cal_tx_iq_balance.cpp
@@ -7,55 +7,18 @@
#include "usrp_cal_utils.hpp"
#include <uhd/utils/safe_main.hpp>
-#include <uhd/utils/thread.hpp>
#include <boost/math/special_functions/round.hpp>
#include <boost/program_options.hpp>
-#include <boost/thread/thread.hpp>
#include <chrono>
#include <complex>
#include <cstdlib>
#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_freq,
- 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);
-
- // values for the wave table lookup
- size_t index = 0;
- const double tx_rate = usrp->get_tx_rate();
- const size_t step = boost::math::iround(wave_table_len * tx_wave_freq / tx_rate);
- wave_table table(tx_wave_ampl);
-
- // fill buff and send until interrupted
- while (not boost::this_thread::interruption_requested()) {
- for (size_t i = 0; i < buff.size(); i++)
- buff[i] = table(index += step);
- 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(
@@ -145,9 +108,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_freq, 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, tx_wave_freq, tx_wave_ampl));
// re-usable buffer for samples
std::vector<samp_type> buff;
@@ -292,10 +256,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, "TX", "tx", "iq", serial);