diff options
author | Matthias P. Braendli <matthias.braendli@mpb.li> | 2015-02-12 07:49:37 +0100 |
---|---|---|
committer | Matthias P. Braendli <matthias.braendli@mpb.li> | 2015-02-12 07:49:37 +0100 |
commit | ec027e05039567b079006035bf99717a3d4e7bf7 (patch) | |
tree | 6f4fcf653e4779b2f4f713d1f9108d859bd666f4 | |
parent | 9e7d0cc81da055bf2a7a6970a5093de52869aec9 (diff) | |
download | uhd-ec027e05039567b079006035bf99717a3d4e7bf7.tar.gz uhd-ec027e05039567b079006035bf99717a3d4e7bf7.tar.bz2 uhd-ec027e05039567b079006035bf99717a3d4e7bf7.zip |
Add detection for LEA-M8Frelease_003_007_001-refclk30_72-lea-m8f
-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 | 7 |
3 files changed, 50 insertions, 8 deletions
diff --git a/host/lib/usrp/gps_ctrl.cpp b/host/lib/usrp/gps_ctrl.cpp index 6f5c75dec..3bf0afd5c 100644 --- a/host/lib/usrp/gps_ctrl.cpp +++ b/host/lib/usrp/gps_ctrl.cpp @@ -63,12 +63,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"); std::map<std::string,std::string> msgs; @@ -123,6 +129,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 sleep(milliseconds(GPS_TIMEOUT_DELAY_MS)); } @@ -139,6 +150,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; @@ -160,6 +176,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"); @@ -168,7 +186,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), @@ -208,13 +228,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 { @@ -247,7 +271,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); @@ -291,7 +321,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"); @@ -344,6 +380,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 91088112c..5a9ce95bb 100644 --- a/host/utils/query_gpsdo_sensors.cpp +++ b/host/utils/query_gpsdo_sensors.cpp @@ -114,7 +114,12 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ std::cout << boost::format("Printing available NMEA strings:\n"); 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("%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") % gga_string.to_pp_string() % rmc_string.to_pp_string(); + + 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("%s\n%s\n%s\n") % gngga_string.to_pp_string() % gnrmc_string.to_pp_string() % gps_time.to_pp_string(); + std::cout << boost::format("UHD Device time: %.0f seconds\n") % (last_pps_time.get_real_secs()); std::cout << boost::format("PC Clock time: %.0f seconds\n") % pc_clock_time; |