diff options
author | Trung N Tran <trung.tran@ettus.com> | 2018-02-23 10:44:39 -0800 |
---|---|---|
committer | Martin Braun <martin.braun@ettus.com> | 2018-04-30 17:02:57 -0700 |
commit | fc67052345373c6d5c1b62064a9f9ef6f888e3ff (patch) | |
tree | 068db86f91641af3f7f2411b77546518f26b7a02 /host | |
parent | 2970aa27ce45d51cefe5c1d35eb8bf8a1e928245 (diff) | |
download | uhd-fc67052345373c6d5c1b62064a9f9ef6f888e3ff.tar.gz uhd-fc67052345373c6d5c1b62064a9f9ef6f888e3ff.tar.bz2 uhd-fc67052345373c6d5c1b62064a9f9ef6f888e3ff.zip |
utils: fix 30s timeout in query_gpsdo_sensors
Diffstat (limited to 'host')
-rw-r--r-- | host/utils/query_gpsdo_sensors.cpp | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/host/utils/query_gpsdo_sensors.cpp b/host/utils/query_gpsdo_sensors.cpp index 7b3c6f057..525c20482 100644 --- a/host/utils/query_gpsdo_sensors.cpp +++ b/host/utils/query_gpsdo_sensors.cpp @@ -20,7 +20,8 @@ #include <cmath> #include <ctime> #include <cstdlib> - +#include <chrono> +#include <thread> namespace po = boost::program_options; namespace fs = boost::filesystem; @@ -160,17 +161,21 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ print_notes(); - // The TCXO has a long warm up time, so wait up to 30 seconds for sensor data to show up - std::cout << "Waiting for the GPSDO to warm up..." << std::endl; - for (size_t i = 0; i < 300; i++) { + // The TCXO has a long warm up time, so wait up to 30 seconds for sensor data + // to show up + std::cout << "Waiting for the GPSDO to warm up..." << std::flush; + auto end = std::chrono::steady_clock::now() + std::chrono::seconds(30); + while (std::chrono::steady_clock::now() < end) { try { - usrp->get_mboard_sensor("gps_locked",0); + usrp->get_mboard_sensor("gps_locked", 0); break; } catch (std::exception &) {} - boost::this_thread::sleep(boost::posix_time::milliseconds(100)); + std::this_thread::sleep_for(std::chrono::milliseconds(250)); + std::cout << "." << std::flush; } + std::cout << std::endl; try { - usrp->get_mboard_sensor("gps_locked",0); + usrp->get_mboard_sensor("gps_locked", 0); } catch (std::exception &) { std::cout << "No response from GPSDO in 30 seconds" << std::endl; return EXIT_FAILURE; |