diff options
| author | Martin Braun <martin.braun@ettus.com> | 2018-08-20 18:03:12 -0700 | 
|---|---|---|
| committer | Martin Braun <martin.braun@ettus.com> | 2018-08-29 15:50:30 -0700 | 
| commit | 09ac6991c3e7afed6bf75dadb16363965fbf54ce (patch) | |
| tree | dc23ccf9b2ba66a3490648c8cd5a3741bb5ac9ca /host/utils/usrp_cal_utils.hpp | |
| parent | bed75f0ccbb6da139283a07c1442293bef95f26a (diff) | |
| download | uhd-09ac6991c3e7afed6bf75dadb16363965fbf54ce.tar.gz uhd-09ac6991c3e7afed6bf75dadb16363965fbf54ce.tar.bz2 uhd-09ac6991c3e7afed6bf75dadb16363965fbf54ce.zip | |
utils: Factor wait_for_lo_lock() out of cal utils
Diffstat (limited to 'host/utils/usrp_cal_utils.hpp')
| -rw-r--r-- | host/utils/usrp_cal_utils.hpp | 16 | 
1 files changed, 16 insertions, 0 deletions
| 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"); +        } +    } +} | 
