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> | 2016-05-25 21:37:51 +0200 |
commit | 46776233e603a6edfadebef55cd7b43b43a26a44 (patch) | |
tree | 7126ce636e2cf2ef3f938d2bcdcd2291ea465641 /host/lib | |
parent | cbae0ea6770b2c7093523050af2dd7e06caef425 (diff) | |
download | uhd-46776233e603a6edfadebef55cd7b43b43a26a44.tar.gz uhd-46776233e603a6edfadebef55cd7b43b43a26a44.tar.bz2 uhd-46776233e603a6edfadebef55cd7b43b43a26a44.zip |
Add detection for LEA-M8F
Diffstat (limited to 'host/lib')
-rw-r--r-- | host/lib/usrp/gps_ctrl.cpp | 49 | ||||
-rw-r--r-- | host/lib/version.cpp | 2 |
2 files changed, 44 insertions, 7 deletions
diff --git a/host/lib/usrp/gps_ctrl.cpp b/host/lib/usrp/gps_ctrl.cpp index 207ef10ab..1cee8e566 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_COMMAND_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 << "; " |