From 428288bbea667419b88c4a5b296beb37aeb48989 Mon Sep 17 00:00:00 2001 From: Martin Braun Date: Tue, 19 Nov 2019 19:41:52 -0800 Subject: 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. --- host/utils/query_gpsdo_sensors.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'host/utils/query_gpsdo_sensors.cpp') 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"); -- cgit v1.2.3