diff options
-rw-r--r-- | host/lib/usrp/gps_ctrl.cpp | 49 | ||||
-rw-r--r-- | host/lib/version.cpp | 2 | ||||
-rw-r--r-- | host/utils/query_gpsdo_sensors.cpp | 4 |
3 files changed, 47 insertions, 8 deletions
diff --git a/host/lib/usrp/gps_ctrl.cpp b/host/lib/usrp/gps_ctrl.cpp index b9d5128bb..cba1706c2 100644 --- a/host/lib/usrp/gps_ctrl.cpp +++ b/host/lib/usrp/gps_ctrl.cpp @@ -89,12 +89,18 @@ private: } std::string update_cached_sensors(const std::string sensor) { - if(not gps_detected() || (gps_type != GPS_TYPE_INTERNAL_GPSDO)) { + if(not gps_detected() || !(gps_type == GPS_TYPE_INTERNAL_GPSDO || gps_type == GPS_TYPE_LEA_M8F)) { UHD_MSG(error) << "get_stat(): unsupported GPS or no GPS detected"; return std::string(); } - const std::list<std::string> list = boost::assign::list_of("GPGGA")("GPRMC")("SERVO"); + std::list<std::string> list = boost::assign::list_of("GPGGA")("GPRMC")("SERVO"); + const std::list<std::string> list_lea_m8f = boost::assign::list_of("GNGGA")("GNRMC"); + + if (gps_type == GPS_TYPE_LEA_M8F) { + list = list_lea_m8f; + } + static const boost::regex status_regex("\\d\\d-\\d\\d-\\d\\d"); static const boost::regex gp_msg_regex("^\\$GP.*,\\*[0-9A-F]{2}$"); std::map<std::string,std::string> msgs; @@ -168,6 +174,11 @@ public: break; } else if(reply.substr(0, 3) == "$GP") i_heard_some_nmea = true; //but keep looking for that "Command Error" response + else if(reply.substr(0, 3) == "$GN") { + // The u-blox LEA-M8F outputs $GNGGA and $GNRMC messages + gps_type = GPS_TYPE_LEA_M8F; + break; + } else if(reply.length() != 0) i_heard_something_weird = true; //probably wrong baud rate } @@ -183,6 +194,11 @@ public: init_gpsdo(); break; + case GPS_TYPE_LEA_M8F: + UHD_MSG(status) << "Found an internal u-blox LEA-M8F GPSDO" << std::endl; + init_lea_m8f(); + break; + case GPS_TYPE_GENERIC_NMEA: UHD_MSG(status) << "Found a generic NMEA GPS device" << std::endl; break; @@ -204,6 +220,8 @@ public: std::vector<std::string> ret = boost::assign::list_of ("gps_gpgga") ("gps_gprmc") + ("gps_gngga") + ("gps_gnrmc") ("gps_time") ("gps_locked") ("gps_servo"); @@ -212,7 +230,9 @@ public: uhd::sensor_value_t get_sensor(std::string key) { if(key == "gps_gpgga" - or key == "gps_gprmc") { + or key == "gps_gprmc" + or key == "gps_gngga" + or key == "gps_gnrmc") { return sensor_value_t( boost::to_upper_copy(key), get_cached_sensor(boost::to_upper_copy(key.substr(4,8)), GPS_NMEA_NORMAL_FRESHNESS, false, false), @@ -252,13 +272,17 @@ private: sleep(milliseconds(GPSDO_STUPID_DELAY_MS)); } + void init_lea_m8f(void) { + // Nothing much to do yet + } + //retrieve a raw NMEA sentence std::string get_nmea(std::string msgtype) { std::string reply; const boost::system_time comm_timeout = boost::get_system_time() + milliseconds(GPS_COMM_TIMEOUT_MS); while(boost::get_system_time() < comm_timeout) { - if(!msgtype.compare("GPRMC")) { + if(! (msgtype.compare("GPRMC") || msgtype.compare("GNRMC")) ) { reply = get_cached_sensor(msgtype, GPS_NMEA_FRESHNESS, true); } else { @@ -291,7 +315,13 @@ private: ptime gps_time; while(error_cnt < 2) { try { - std::string reply = get_nmea("GPRMC"); + std::string reply; + if (gps_type == GPS_TYPE_LEA_M8F) { + reply = get_nmea("GNRMC"); + } + else { + reply = get_nmea("GPRMC"); + } std::string datestr = get_token(reply, 9); std::string timestr = get_token(reply, 1); @@ -335,7 +365,13 @@ private: int error_cnt = 0; while(error_cnt < 3) { try { - std::string reply = get_cached_sensor("GPGGA", GPS_LOCK_FRESHNESS, false, false); + std::string reply; + if (gps_type == GPS_TYPE_LEA_M8F) { + reply = get_cached_sensor("GNGGA", GPS_LOCK_FRESHNESS, false, false); + } + else { + reply = get_cached_sensor("GPGGA", GPS_LOCK_FRESHNESS, false, false); + } if(reply.size() <= 1) return false; return (get_token(reply, 6) != "0"); @@ -388,6 +424,7 @@ private: enum { GPS_TYPE_INTERNAL_GPSDO, + GPS_TYPE_LEA_M8F, GPS_TYPE_GENERIC_NMEA, GPS_TYPE_NONE } gps_type; diff --git a/host/lib/version.cpp b/host/lib/version.cpp index 2b7125e55..24d4bc2b4 100644 --- a/host/lib/version.cpp +++ b/host/lib/version.cpp @@ -22,7 +22,7 @@ #ifndef UHD_DONT_PRINT_SYSTEM_INFO UHD_STATIC_BLOCK(print_system_info){ - std::cout + std::cerr << BOOST_PLATFORM << "; " << BOOST_COMPILER << "; " << "Boost_" << BOOST_VERSION << "; " diff --git a/host/utils/query_gpsdo_sensors.cpp b/host/utils/query_gpsdo_sensors.cpp index 05f918eb4..042530a7a 100644 --- a/host/utils/query_gpsdo_sensors.cpp +++ b/host/utils/query_gpsdo_sensors.cpp @@ -116,8 +116,10 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ 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"); + uhd::sensor_value_t gngga_string = usrp->get_mboard_sensor("gps_gngga"); + uhd::sensor_value_t gnrmc_string = usrp->get_mboard_sensor("gps_gnrmc"); std::cout << boost::format("Printing available NMEA strings:\n"); - std::cout << boost::format("%s\n%s\n%s\n") % gga_string.to_pp_string() % rmc_string.to_pp_string() % gps_time.to_pp_string(); + std::cout << boost::format("%s\n%s\n%s\n%s\n%s\n") % gga_string.to_pp_string() % rmc_string.to_pp_string() % gngga_string.to_pp_string() % gnrmc_string.to_pp_string() % gps_time.to_pp_string(); } catch (std::exception &e) { std::cout << "NMEA strings not implemented for this device." << std::endl; } |