From ec75303792bfecfcc921295f0f48517b8dc26d35 Mon Sep 17 00:00:00 2001 From: Nicholas Corgan Date: Thu, 16 Jun 2016 08:02:11 -0700 Subject: Fixed minor warnings * Mismatched printf format strings * Number truncation * Unreferenced variables --- host/utils/query_gpsdo_sensors.cpp | 6 +++--- host/utils/uhd_usrp_probe.cpp | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'host/utils') diff --git a/host/utils/query_gpsdo_sensors.cpp b/host/utils/query_gpsdo_sensors.cpp index 21d26e81e..01a5adec5 100644 --- a/host/utils/query_gpsdo_sensors.cpp +++ b/host/utils/query_gpsdo_sensors.cpp @@ -91,7 +91,7 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ std::cout << "trying \"external\"..." <set_time_source("external"); - } catch (uhd::value_error &e) { + } catch (uhd::value_error&) { std::cout << "\"external\" failed, too." << std::endl; } } @@ -115,7 +115,7 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ std::cout << "trying \"external\"..." <set_clock_source("external"); - } catch (uhd::value_error &e) { + } catch (uhd::value_error&) { std::cout << "\"external\" failed, too." << std::endl; } } @@ -179,7 +179,7 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ 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 &e) { + } catch (uhd::lookup_error&) { std::cout << "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(); diff --git a/host/utils/uhd_usrp_probe.cpp b/host/utils/uhd_usrp_probe.cpp index 4a84fef55..ae86b0dba 100644 --- a/host/utils/uhd_usrp_probe.cpp +++ b/host/utils/uhd_usrp_probe.cpp @@ -1,5 +1,5 @@ // -// Copyright 2010-2011,2015 Ettus Research LLC +// Copyright 2010-2011,2015-2016 Ettus Research LLC // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by @@ -172,7 +172,7 @@ static std::string get_mboard_pp_string(property_tree::sptr tree, const fs_path ss << make_border(get_dboard_pp_string("TX", tree, path / "dboards" / name)); } } - catch (const uhd::lookup_error &e) { + catch (const uhd::lookup_error&) { /* nop */ } return ss.str(); -- cgit v1.2.3 From f86c263682c8250b206abfe8e439e95bef947636 Mon Sep 17 00:00:00 2001 From: Nicholas Corgan Date: Wed, 15 Jun 2016 07:19:58 -0700 Subject: query_gpsdo_sensors: added OctoClock-G support --- host/utils/query_gpsdo_sensors.cpp | 39 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) (limited to 'host/utils') diff --git a/host/utils/query_gpsdo_sensors.cpp b/host/utils/query_gpsdo_sensors.cpp index 01a5adec5..7c5728e39 100644 --- a/host/utils/query_gpsdo_sensors.cpp +++ b/host/utils/query_gpsdo_sensors.cpp @@ -19,6 +19,7 @@ #include #include #include +#include #include #include #include @@ -41,6 +42,38 @@ void print_notes(void) { std::cout << boost::format("****************************************************************************************************************\n"); } +int query_clock_sensors(const std::string &args) { + std::cout << boost::format("\nCreating the clock device with: %s...\n") % args; + uhd::usrp_clock::multi_usrp_clock::sptr clock = uhd::usrp_clock::multi_usrp_clock::make(args); + + //Verify GPS sensors are present + std::vector 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 servo_string = clock->get_sensor("gps_servo"); + 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("\nPrinting GPS servo status:\n"); + std::cout << boost::format("%s\n\n") % servo_string.to_pp_string(); + } catch (uhd::lookup_error &e) { + std::cout << "NMEA strings not implemented for this device." << std::endl; + } + std::cout << boost::format("GPS Epoch time: %.5f seconds\n") % clock->get_sensor("gps_time").to_real(); + std::cout << boost::format("PC Clock time: %.5f seconds\n") % time(NULL); + + //finished + std::cout << boost::format("\nDone!\n\n"); + + return EXIT_SUCCESS; +} + int UHD_SAFE_MAIN(int argc, char *argv[]){ uhd::set_thread_priority_safe(); @@ -51,6 +84,7 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ desc.add_options() ("help", "help message") ("args", po::value(&args)->default_value(""), "Device address arguments specifying a single USRP") + ("clock", "query a clock device's sensors") ; po::variables_map vm; po::store(po::parse_command_line(argc, argv, desc), vm); @@ -65,6 +99,11 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ return EXIT_FAILURE; } + //If specified, query a clock device instead + if(vm.count("clock")) { + return query_clock_sensors(args); + } + //Create a USRP device std::cout << boost::format("\nCreating the USRP device with: %s...\n") % args; uhd::usrp::multi_usrp::sptr usrp = uhd::usrp::multi_usrp::make(args); -- cgit v1.2.3