diff options
author | Martin Braun <martin.braun@ettus.com> | 2019-11-19 19:41:52 -0800 |
---|---|---|
committer | Martin Braun <martin.braun@ettus.com> | 2019-11-21 15:02:32 -0800 |
commit | 428288bbea667419b88c4a5b296beb37aeb48989 (patch) | |
tree | 38f15d90f85a2624c934becb8ee3b7597a30a2cd | |
parent | 473a3e148a99e258e26a7f09c2d82bb8ed4e50f6 (diff) | |
download | uhd-428288bbea667419b88c4a5b296beb37aeb48989.tar.gz uhd-428288bbea667419b88c4a5b296beb37aeb48989.tar.bz2 uhd-428288bbea667419b88c4a5b296beb37aeb48989.zip |
utils: query_gpsdo_sensors: Fix ref_lock wait loop
The old loop didn't have any output, and had an inaccurate timeout. We
now use a timer for a 30 second timeout, and print a . every time we
poll the sensor.
-rw-r--r-- | host/utils/query_gpsdo_sensors.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/host/utils/query_gpsdo_sensors.cpp b/host/utils/query_gpsdo_sensors.cpp index 4a8aa24d2..ecc0048a7 100644 --- a/host/utils/query_gpsdo_sensors.cpp +++ b/host/utils/query_gpsdo_sensors.cpp @@ -162,10 +162,13 @@ int UHD_SAFE_MAIN(int argc, char* argv[]) // Check for ref lock if (std::find(sensor_names.begin(), sensor_names.end(), "ref_locked") != sensor_names.end()) { + std::cout << "Waiting for ref_locked..." << std::flush; uhd::sensor_value_t ref_locked = usrp->get_mboard_sensor("ref_locked", 0); - for (size_t i = 0; not ref_locked.to_bool() and i < 300; i++) { + auto end = std::chrono::steady_clock::now() + std::chrono::seconds(30); + while (!ref_locked.to_bool() && std::chrono::steady_clock::now() < end) { std::this_thread::sleep_for(std::chrono::milliseconds(100)); ref_locked = usrp->get_mboard_sensor("ref_locked", 0); + std::cout << "." << std::flush; } if (not ref_locked.to_bool()) { std::cout << boost::format("USRP NOT Locked to Reference.\n"); |