diff options
Diffstat (limited to 'host/utils/query_gpsdo_sensors.cpp')
-rw-r--r-- | host/utils/query_gpsdo_sensors.cpp | 59 |
1 files changed, 53 insertions, 6 deletions
diff --git a/host/utils/query_gpsdo_sensors.cpp b/host/utils/query_gpsdo_sensors.cpp index d909f83a9..002f2790c 100644 --- a/host/utils/query_gpsdo_sensors.cpp +++ b/host/utils/query_gpsdo_sensors.cpp @@ -25,6 +25,9 @@ namespace po = boost::program_options; namespace fs = boost::filesystem; +const size_t WARMUP_TIMEOUT_MS = 30000; +const size_t LOCK_TIMEOUT_MS = 60000; + void print_notes(void) { // Helpful notes std::cout << boost::format("**************************************Helpful Notes on Clock/PPS Selection**************************************\n"); @@ -41,18 +44,23 @@ int query_clock_sensors(const std::string &args) { std::vector<std::string> sensor_names = clock->get_sensor_names(0); if(std::find(sensor_names.begin(), sensor_names.end(), "gps_locked") == sensor_names.end()) { std::cout << boost::format("\ngps_locked sensor not found. This could mean that this unit does not have a GPSDO.\n\n"); - return EXIT_FAILURE; } // Print NMEA strings try { - uhd::sensor_value_t gga_string = clock->get_sensor("gps_gpgga"); - uhd::sensor_value_t rmc_string = clock->get_sensor("gps_gprmc"); + uhd::sensor_value_t gpgga_string = clock->get_sensor("gps_gpgga"); + uhd::sensor_value_t gprmc_string = clock->get_sensor("gps_gprmc"); + uhd::sensor_value_t gngga_string = clock->get_sensor("gps_gngga"); + uhd::sensor_value_t gnrmc_string = clock->get_sensor("gps_gnrmc"); uhd::sensor_value_t servo_string = clock->get_sensor("gps_servo"); + uhd::sensor_value_t timelock_string = clock->get_sensor("gps_timelock"); std::cout << boost::format("\nPrinting available NMEA strings:\n"); - std::cout << boost::format("%s\n%s\n") % gga_string.to_pp_string() % rmc_string.to_pp_string(); + std::cout << boost::format("%s\n%s\n") % gpgga_string.to_pp_string() % gprmc_string.to_pp_string(); + std::cout << boost::format("%s\n%s\n") % gngga_string.to_pp_string() % gnrmc_string.to_pp_string(); std::cout << boost::format("\nPrinting GPS servo status:\n"); std::cout << boost::format("%s\n\n") % servo_string.to_pp_string(); + std::cout << boost::format("\nPrinting GPS timelock:\n"); + std::cout << boost::format("%s\n\n") % timelock_string.to_pp_string(); } catch (const uhd::lookup_error &) { std::cout << "NMEA strings not implemented for this device." << std::endl; } @@ -103,6 +111,12 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ //Verify GPS sensors are present (i.e. EEPROM has been burnt) std::vector<std::string> sensor_names = usrp->get_mboard_sensor_names(0); + std::cout << " Sensors: " << std::endl; + for (const auto& name : sensor_names) { + std::cout << " Sensor: " << name << std::endl; + } + + if (std::find(sensor_names.begin(), sensor_names.end(), "gps_locked") == sensor_names.end()) { std::cout << boost::format("\ngps_locked sensor not found. This could mean that you have not installed the GPSDO correctly.\n\n"); std::cout << boost::format("Visit one of these pages if the problem persists:\n"); @@ -174,6 +188,7 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ std::cout << "." << std::flush; } std::cout << std::endl; + try { usrp->get_mboard_sensor("gps_locked", 0); } catch (std::exception &) { @@ -183,6 +198,20 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ std::cout << "The GPSDO is warmed up and talking." << std::endl; //Check for GPS lock + auto exit_time = std::chrono::steady_clock::now() + std::chrono::milliseconds(LOCK_TIMEOUT_MS); + while (std::chrono::steady_clock::now() < exit_time) { + uhd::sensor_value_t gps_locked = usrp->get_mboard_sensor("gps_locked",0);; + + if (gps_locked.to_bool()) { + break; + } + else { + std::cout << "gps_locked = " << gps_locked.value << std::endl; + } + + std::this_thread::sleep_for(std::chrono::seconds(1)); + } + uhd::sensor_value_t gps_locked = usrp->get_mboard_sensor("gps_locked",0);; if(not gps_locked.to_bool()) { std::cout << boost::format("\nGPS does not have lock. Wait a few minutes and try again.\n"); @@ -225,14 +254,32 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ % pps_seconds % gps_seconds << std::endl; + std::cout << " Sensors: " << std::endl; + for (const auto& name : usrp->get_mboard_sensor_names(0)) { + std::cout << " Sensor: " << name << std::endl; + } + //print NMEA strings try { uhd::sensor_value_t gga_string = usrp->get_mboard_sensor("gps_gpgga"); uhd::sensor_value_t rmc_string = usrp->get_mboard_sensor("gps_gprmc"); std::cout << boost::format("Printing available NMEA strings:\n"); std::cout << boost::format("%s\n%s\n") % gga_string.to_pp_string() % rmc_string.to_pp_string(); - } catch (uhd::lookup_error&) { - std::cout << "NMEA strings not implemented for this device." << std::endl; + } catch (const uhd::lookup_error&) { + std::cout << "GP NMEA strings not implemented for this device." << std::endl; + } catch (const uhd::value_error&) { + std::cout << "GP NMEA strings not implemented for this device." << std::endl; + } + + try { + uhd::sensor_value_t gga_string = usrp->get_mboard_sensor("gps_gngga"); + uhd::sensor_value_t rmc_string = usrp->get_mboard_sensor("gps_gnrmc"); + std::cout << boost::format("Printing available NMEA strings:\n"); + std::cout << boost::format("%s\n%s\n") % gga_string.to_pp_string() % rmc_string.to_pp_string(); + } catch (const uhd::lookup_error&) { + std::cout << "GN NMEA strings not implemented for this device." << std::endl; + } catch (const uhd::value_error&) { + std::cout << "GN NMEA strings not implemented for this device." << std::endl; } std::cout << boost::format("GPS Epoch time at last PPS: %.5f seconds\n") % usrp->get_mboard_sensor("gps_time").to_real(); std::cout << boost::format("UHD Device time last PPS: %.5f seconds\n") % (usrp->get_time_last_pps().get_real_secs()); |