aboutsummaryrefslogtreecommitdiffstats
path: root/host/utils/uhd_cal_tx_dc_offset.cpp
diff options
context:
space:
mode:
authorNicolas Cuervo <nicolas.cuervo@ettus.com>2016-10-03 16:39:30 -0700
committerMartin Braun <martin.braun@ettus.com>2018-04-18 15:05:22 -0700
commita8c74853f9bc73a796c553fc7cebb14266775e59 (patch)
tree5f1294e4c1672ebb137c15054759dd188cfb4af7 /host/utils/uhd_cal_tx_dc_offset.cpp
parent0e909a2a9d2432c1f935f79953e78663b4129132 (diff)
downloaduhd-a8c74853f9bc73a796c553fc7cebb14266775e59.tar.gz
uhd-a8c74853f9bc73a796c553fc7cebb14266775e59.tar.bz2
uhd-a8c74853f9bc73a796c553fc7cebb14266775e59.zip
cal_utils: logic to handle eventual U's during calibration
For every frequency point, the cal utils will detect underruns and retry a calibration measurement up to 10 times before failing.
Diffstat (limited to 'host/utils/uhd_cal_tx_dc_offset.cpp')
-rw-r--r--host/utils/uhd_cal_tx_dc_offset.cpp32
1 files changed, 25 insertions, 7 deletions
diff --git a/host/utils/uhd_cal_tx_dc_offset.cpp b/host/utils/uhd_cal_tx_dc_offset.cpp
index 0a11cc223..4adea9c2a 100644
--- a/host/utils/uhd_cal_tx_dc_offset.cpp
+++ b/host/utils/uhd_cal_tx_dc_offset.cpp
@@ -24,17 +24,13 @@ namespace po = boost::program_options;
/***********************************************************************
* Transmit thread
**********************************************************************/
-static void tx_thread(uhd::usrp::multi_usrp::sptr usrp, const double tx_wave_freq, const double tx_wave_ampl)
+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)
{
uhd::set_thread_priority_safe();
// set max TX gain
usrp->set_tx_gain(usrp->get_tx_gain_range().stop());
- //create a transmit streamer
- uhd::stream_args_t stream_args("fc32"); //complex floats
- uhd::tx_streamer::sptr tx_stream = usrp->get_tx_stream(stream_args);
-
//setup variables and allocate buffer
uhd::tx_metadata_t md;
md.has_time_spec = false;
@@ -146,9 +142,12 @@ int UHD_SAFE_MAIN(int argc, char *argv[])
uhd::stream_args_t stream_args("fc32"); //complex floats
uhd::rx_streamer::sptr rx_stream = usrp->get_rx_stream(stream_args);
+ //create a transmit streamer
+ uhd::tx_streamer::sptr tx_stream = usrp->get_tx_stream(stream_args);
+
//create a transmitter thread
boost::thread_group threads;
- threads.create_thread(boost::bind(&tx_thread, usrp, tx_wave_freq, tx_wave_ampl));
+ threads.create_thread(boost::bind(&tx_thread, usrp, tx_stream, tx_wave_freq, tx_wave_ampl));
//re-usable buffer for samples
std::vector<samp_type> buff;
@@ -186,6 +185,7 @@ int UHD_SAFE_MAIN(int argc, char *argv[])
//set RX gain
usrp->set_rx_gain(0);
+ size_t tx_error_count = 0;
for (double tx_lo_i = freq_start; tx_lo_i <= freq_stop; tx_lo_i += freq_step)
{
const double tx_lo = tune_rx_and_tx(usrp, tx_lo_i, rx_offset);
@@ -224,6 +224,22 @@ int UHD_SAFE_MAIN(int argc, char *argv[])
//receive some samples
capture_samples(usrp, rx_stream, buff, nsamps);
+ //check for TX errors in the current captured iteration
+ if (has_tx_error(tx_stream)){
+ std::cout
+ << "[WARNING] TX error detected! "
+ << "Repeating current iteration"
+ << std::endl;
+ // Undo the Q correction step
+ q_corr -= q_corr_step;
+ tx_error_count++;
+ if (tx_error_count >= MAX_NUM_TX_ERRORS) {
+ throw uhd::runtime_error(
+ "Too many TX errors. Aborting calibration."
+ );
+ }
+ continue;
+ }
const double dc_dbrms = compute_tone_dbrms(buff, bb_dc_freq/actual_rx_rate);
if (dc_dbrms < best_dc_dbrms)
@@ -258,7 +274,9 @@ int UHD_SAFE_MAIN(int argc, char *argv[])
std::cout << "." << std::flush;
}
- }
+ // Reset underrun counts, start a new counter for the next frequency
+ tx_error_count = 0;
+ } // end for each frequency loop
std::cout << std::endl;