aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Braun <martin.braun@ettus.com>2018-08-20 18:03:12 -0700
committerMartin Braun <martin.braun@ettus.com>2018-08-29 15:50:30 -0700
commit09ac6991c3e7afed6bf75dadb16363965fbf54ce (patch)
treedc23ccf9b2ba66a3490648c8cd5a3741bb5ac9ca
parentbed75f0ccbb6da139283a07c1442293bef95f26a (diff)
downloaduhd-09ac6991c3e7afed6bf75dadb16363965fbf54ce.tar.gz
uhd-09ac6991c3e7afed6bf75dadb16363965fbf54ce.tar.bz2
uhd-09ac6991c3e7afed6bf75dadb16363965fbf54ce.zip
utils: Factor wait_for_lo_lock() out of cal utils
-rw-r--r--host/utils/uhd_cal_rx_iq_balance.cpp9
-rw-r--r--host/utils/uhd_cal_tx_dc_offset.cpp9
-rw-r--r--host/utils/uhd_cal_tx_iq_balance.cpp9
-rw-r--r--host/utils/usrp_cal_utils.hpp16
4 files changed, 19 insertions, 24 deletions
diff --git a/host/utils/uhd_cal_rx_iq_balance.cpp b/host/utils/uhd_cal_rx_iq_balance.cpp
index 470a66f9c..81a04b6f9 100644
--- a/host/utils/uhd_cal_rx_iq_balance.cpp
+++ b/host/utils/uhd_cal_rx_iq_balance.cpp
@@ -74,14 +74,7 @@ static double tune_rx_and_tx(uhd::usrp::multi_usrp::sptr usrp, const double rx_l
tx_tune_req.dsp_freq = tx_freq - max_fe_tx_freq;
usrp->set_tx_freq(tx_tune_req);
- //wait for the LOs to become locked
- std::this_thread::sleep_for(std::chrono::milliseconds(50));
- boost::system_time start = boost::get_system_time();
- while (not usrp->get_tx_sensor("lo_locked").to_bool() or not usrp->get_rx_sensor("lo_locked").to_bool())
- {
- if (boost::get_system_time() > start + boost::posix_time::milliseconds(100))
- throw std::runtime_error("timed out waiting for TX and/or RX LO to lock");
- }
+ wait_for_lo_lock(usrp);
return usrp->get_rx_freq();
}
diff --git a/host/utils/uhd_cal_tx_dc_offset.cpp b/host/utils/uhd_cal_tx_dc_offset.cpp
index ecd676e07..6c35f017f 100644
--- a/host/utils/uhd_cal_tx_dc_offset.cpp
+++ b/host/utils/uhd_cal_tx_dc_offset.cpp
@@ -81,14 +81,7 @@ static double tune_rx_and_tx(uhd::usrp::multi_usrp::sptr usrp, const double tx_l
rx_tune_req.dsp_freq = rx_freq - max_fe_rx_freq;
usrp->set_rx_freq(rx_tune_req);
- //wait for the LOs to become locked
- std::this_thread::sleep_for(std::chrono::milliseconds(50));
- boost::system_time start = boost::get_system_time();
- while (not usrp->get_tx_sensor("lo_locked").to_bool() or not usrp->get_rx_sensor("lo_locked").to_bool())
- {
- if (boost::get_system_time() > start + boost::posix_time::milliseconds(100))
- throw std::runtime_error("timed out waiting for TX and/or RX LO to lock");
- }
+ wait_for_lo_lock(usrp);
return usrp->get_tx_freq();
}
diff --git a/host/utils/uhd_cal_tx_iq_balance.cpp b/host/utils/uhd_cal_tx_iq_balance.cpp
index da8807479..d5079431b 100644
--- a/host/utils/uhd_cal_tx_iq_balance.cpp
+++ b/host/utils/uhd_cal_tx_iq_balance.cpp
@@ -78,14 +78,7 @@ static double tune_rx_and_tx(uhd::usrp::multi_usrp::sptr usrp, const double tx_l
rx_tune_req.dsp_freq = rx_freq - max_fe_rx_freq;
usrp->set_rx_freq(rx_tune_req);
- //wait for the LOs to become locked
- std::this_thread::sleep_for(std::chrono::milliseconds(50));
- boost::system_time start = boost::get_system_time();
- while (not usrp->get_tx_sensor("lo_locked").to_bool() or not usrp->get_rx_sensor("lo_locked").to_bool())
- {
- if (boost::get_system_time() > start + boost::posix_time::milliseconds(100))
- throw std::runtime_error("timed out waiting for TX and/or RX LO to lock");
- }
+ wait_for_lo_lock(usrp);
return usrp->get_tx_freq();
}
diff --git a/host/utils/usrp_cal_utils.hpp b/host/utils/usrp_cal_utils.hpp
index 88fedcbd4..8fde78e1f 100644
--- a/host/utils/usrp_cal_utils.hpp
+++ b/host/utils/usrp_cal_utils.hpp
@@ -19,6 +19,8 @@
#include <cmath>
#include <cstdlib>
#include <fstream>
+#include <chrono>
+#include <thread>
namespace fs = boost::filesystem;
@@ -395,3 +397,17 @@ bool has_tx_error(uhd::tx_streamer::sptr tx_stream)
| uhd::async_metadata_t::EVENT_CODE_SEQ_ERROR_IN_BURST
);
}
+
+void wait_for_lo_lock(uhd::usrp::multi_usrp::sptr usrp)
+{
+ std::this_thread::sleep_for(std::chrono::milliseconds(50));
+ const auto timeout =
+ std::chrono::steady_clock::now() + std::chrono::milliseconds(100);
+ while (not usrp->get_tx_sensor("lo_locked").to_bool()
+ or not usrp->get_rx_sensor("lo_locked").to_bool()) {
+ if (std::chrono::steady_clock::now() > timeout) {
+ throw std::runtime_error(
+ "timed out waiting for TX and/or RX LO to lock");
+ }
+ }
+}