From 21b9b097329453bb3c3666d9429a1d1c7257efae Mon Sep 17 00:00:00 2001 From: "Matthias P. Braendli" Date: Wed, 14 Feb 2018 10:34:54 +0100 Subject: Fix handling of GPS sensors --- src/output/USRPTime.cpp | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) (limited to 'src/output/USRPTime.cpp') diff --git a/src/output/USRPTime.cpp b/src/output/USRPTime.cpp index 8de86fb..56bdf50 100644 --- a/src/output/USRPTime.cpp +++ b/src/output/USRPTime.cpp @@ -48,14 +48,29 @@ static bool check_gps_timelock(uhd::usrp::multi_usrp::sptr& usrp) usrp->get_mboard_sensor("gps_timelock", 0).to_pp_string(); if (sensor_value.find("TIME LOCKED") == string::npos) { - etiLog.level(warn) << "OutputUHD: gps_timelock " << sensor_value; + + const string gngga = + usrp->get_mboard_sensor("gps_gngga", 0).to_pp_string(); + + std::stringstream ss(gngga); + std::string item; + std::vector elems; + while (std::getline(ss, item, ',')) { + elems.push_back(item); + } + + const auto num_svs = (elems.size() >= 7) ? elems[7] : "?"; + + etiLog.level(info) << "OutputUHD: " << num_svs << " SVs," + " gps_timelock " << sensor_value; return false; } return true; } - catch (const uhd::lookup_error &e) { - etiLog.level(warn) << "OutputUHD: no gps_timelock sensor"; + catch (const uhd::exception &e) { + etiLog.level(warn) << "OutputUHD: no gps_timelock sensor: " << + e.what(); return false; } } @@ -74,8 +89,9 @@ static bool check_gps_locked(uhd::usrp::multi_usrp::sptr& usrp) return true; } - catch (const uhd::lookup_error &e) { - etiLog.level(warn) << "OutputUHD: no gps_locked sensor"; + catch (const uhd::exception &e) { + etiLog.level(warn) << "OutputUHD: no gps_locked sensor" << + e.what(); return false; } } @@ -100,7 +116,7 @@ USRPTime::USRPTime( } now = system_clock::now(); - this_thread::sleep_for(seconds(1)); + this_thread::sleep_for(seconds(2)); } if (not checkfunc(m_usrp)) { -- cgit v1.2.3