From fc67052345373c6d5c1b62064a9f9ef6f888e3ff Mon Sep 17 00:00:00 2001 From: Trung N Tran Date: Fri, 23 Feb 2018 10:44:39 -0800 Subject: utils: fix 30s timeout in query_gpsdo_sensors --- host/utils/query_gpsdo_sensors.cpp | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'host') 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 #include #include - +#include +#include 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; -- cgit v1.2.3