summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--host/docs/sync.rst19
-rw-r--r--host/docs/usrp2.rst5
-rw-r--r--host/lib/usrp/gps_ctrl.cpp22
-rw-r--r--host/lib/usrp/usrp2/mboard_impl.cpp20
4 files changed, 44 insertions, 22 deletions
diff --git a/host/docs/sync.rst b/host/docs/sync.rst
index 9284d8e33..3cb13fbf3 100644
--- a/host/docs/sync.rst
+++ b/host/docs/sync.rst
@@ -102,22 +102,11 @@ and the user can also parse this string to determine GPS time:
usrp->set_time_next_pps(uhd::time_spec_t(gps_time+1));
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-Method 3 - query the gps_time sensor
+Method 3 - internal GPSDO
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-This is a variant of method 2 for USRPs with internal GPSDOs.
-The user can query the gps_time sensor to wait for the NMEA string.
-
-::
-
- //wait for NMEA string from internal GPSDO
- usrp->get_mboard_sensor("gps_time");
- usrp->set_time_next_pps(uhd::time_spec_t(0.0));
-
- -- OR --
-
- //wait for the NMEA string and set GPS time
- const time_t gps_time = usrp->get_mboard_sensor("gps_time").to_int();
- usrp->set_time_next_pps(uhd::time_spec_t(gps_time+1));
+USRPs with internal GPSDOs properly configured will automatically
+configure themselves to set the VITA time to current UTC time. See the
+GPSDO application note for more details.
------------------------------------------------------------------------
Synchronizing channel phase
diff --git a/host/docs/usrp2.rst b/host/docs/usrp2.rst
index 88b217f1b..fa811d0f6 100644
--- a/host/docs/usrp2.rst
+++ b/host/docs/usrp2.rst
@@ -349,9 +349,8 @@ Test the PPS input with the following app:
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Internal GPSDO
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-USRP-N2XX models can have an optional internal GPSDO.
-To use the GPSDO with UHD, you must burn an EEPROM setting
-so that UHD knows that the internal GPSDO was installed.
+Please see the GPSDO application note for information on configuring and
+using the internal GPSDO.
**Installation instructions:**
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();
}
diff --git a/host/lib/usrp/usrp2/mboard_impl.cpp b/host/lib/usrp/usrp2/mboard_impl.cpp
index 3733915a2..12fff96d0 100644
--- a/host/lib/usrp/usrp2/mboard_impl.cpp
+++ b/host/lib/usrp/usrp2/mboard_impl.cpp
@@ -149,7 +149,13 @@ usrp2_mboard_impl::usrp2_mboard_impl(
(_mimo_clocking_mode_is_master?"master":"slave") << std::endl;
//init the clock config
- _clock_config = clock_config_t::internal();
+ if(_iface->mb_eeprom["gpsdo"] == "internal" or
+ _iface->mb_eeprom["gpsdo"] == "external") {
+ _clock_config = clock_config_t::external();
+ }
+ else {
+ _clock_config = clock_config_t::internal();
+ }
update_clock_config();
//init the codec before the dboard
@@ -176,9 +182,15 @@ usrp2_mboard_impl::usrp2_mboard_impl(
//------------------------------------------------------------------
//initialize VITA time to GPS time
- if(_gps_ctrl.get() and _gps_ctrl->gps_detected()) {
- UHD_MSG(status) << "Setting device time to GPS time...\n";
- set_time_spec(time_spec_t(double(_gps_ctrl->get_sensor("gps_time").to_int()+1)), false);
+ if( _gps_ctrl.get()
+ and _gps_ctrl->gps_detected()) {
+ if(_gps_ctrl->get_sensor("gps_locked").to_bool()) {
+ UHD_MSG(status) << "Setting device time to GPS time...\n";
+ set_time_spec(time_spec_t(double(_gps_ctrl->get_sensor("gps_time").to_int()+1)), false);
+ }
+ else {
+ UHD_MSG(status) << "GPS not locked to satellites. Not initializing VITA time.";
+ }
}
}