diff options
author | Nick Foster <nick@ettus.com> | 2011-06-17 15:09:16 -0700 |
---|---|---|
committer | Nick Foster <nick@ettus.com> | 2011-06-17 15:09:16 -0700 |
commit | 6f6364f73aad1262fdbe88ad97128f7844764c99 (patch) | |
tree | fd8f72d6143e7e543e4e62b2f4c7f9acf94efbb7 /host/lib/usrp/gps_ctrl.cpp | |
parent | 7af605b247ee9331c29c23229252a101b7d40352 (diff) | |
download | uhd-6f6364f73aad1262fdbe88ad97128f7844764c99.tar.gz uhd-6f6364f73aad1262fdbe88ad97128f7844764c99.tar.bz2 uhd-6f6364f73aad1262fdbe88ad97128f7844764c99.zip |
UHD: implemented gps_locked sensor. usrp2 mboard doesn't init VITA time if time not valid.
Diffstat (limited to 'host/lib/usrp/gps_ctrl.cpp')
-rw-r--r-- | host/lib/usrp/gps_ctrl.cpp | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/host/lib/usrp/gps_ctrl.cpp b/host/lib/usrp/gps_ctrl.cpp index 55f46ffb3..2c2843877 100644 --- a/host/lib/usrp/gps_ctrl.cpp +++ b/host/lib/usrp/gps_ctrl.cpp @@ -184,6 +184,24 @@ public: return (gps_type != GPS_TYPE_NONE); } + bool locked(void) { + std::string reply = get_nmea("GPGGA"); + if(reply.size() <= 1) return false; + + boost::tokenizer<boost::escaped_list_separator<char> > tok(reply); + std::vector<std::string> toked; + + tok.assign(reply); + toked.assign(tok.begin(), tok.end()); + + if(toked.size() != 15) { + UHD_MSG(error) << "gps_locked: invalid GPGGA response"; + return false; + } + + return (toked[6] != "0"); //sorry, 2d fixes don't count =D + } + //return a list of supported sensors std::vector<std::string> get_sensors(void) { std::vector<std::string> ret; @@ -191,6 +209,7 @@ public: ret.push_back("gps_gprmc"); ret.push_back("gps_gpgsa"); ret.push_back("gps_time"); + ret.push_back("gps_locked"); return ret; } @@ -206,6 +225,9 @@ public: else if(key == "gps_time") { return sensor_value_t("GPS epoch time", int(get_epoch_time()), "seconds"); } + else if(key == "gps_locked") { + return sensor_value_t("GPS lock status", locked(), "locked", "unlocked"); + } else { UHD_THROW_PROP_GET_ERROR(); } |