summaryrefslogtreecommitdiff
path: root/gpsmon.c
diff options
context:
space:
mode:
authorFred Wright <fw@fwright.net>2016-12-22 19:47:25 -0800
committerFred Wright <fw@fwright.net>2016-12-23 13:24:12 -0800
commite2471ddd5934d24dff6802bdbe4b38e83878cc01 (patch)
tree0482bdba58ea4ed5a890e5a018f54ec4ebb25c4c /gpsmon.c
parent79c69b2b12e5f8ee3aa3f50b8886a0a7bbdd73f7 (diff)
downloadgpsd-e2471ddd5934d24dff6802bdbe4b38e83878cc01.tar.gz
Adds Linux "fake PPS" detection and avoidance.
If the Linux kernel is built with CONFIG_PPS_CLIENT_KTIMER=y, then a synthetic PPS source is added to allow testing without a real PPS source. However, this source doesn't even run at exactly 1Hz, so any attempt to use it for real time synchronization is disastrous. To make matters worse, this is usually the first PPS driver configured, causing it to appear as /dev/pps0, which is the implied PPS device used by the "Magic HAT" kludge. This change adds detection for the fake source (based on its name), both to provide a warning if it is configured explicitly, and to skip over it when applying the "Magic HAT" kludge. TESTED: Tested both gpsmon and gpsd on a Beaglebone Black with added symlinks for testing "Magic HAT". Did this with kernels with and without the KTIMER enabled. Verified that the proper PPS device is selected by "Magic HAT", and that a warning is generated when expected.
Diffstat (limited to 'gpsmon.c')
-rw-r--r--gpsmon.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/gpsmon.c b/gpsmon.c
index 9a02ef62..4183b585 100644
--- a/gpsmon.c
+++ b/gpsmon.c
@@ -1322,14 +1322,16 @@ int main(int argc, char **argv)
/*
* The HAT kludge. If we're using the HAT GPS on a
* Raspberry Pi or a workalike like the ODROIDC2, and
- * there is a static /dev/pps0, and we have access because
+ * there is a static "first PPS", and we have access because
* we're root, assume we want to use KPPS.
*/
- if ((strcmp(session.pps_thread.devicename, MAGIC_HAT_GPS) == 0
- || strcmp(session.pps_thread.devicename, MAGIC_LINK_GPS) == 0)
- && access("/dev/pps0", R_OK | W_OK) == 0)
- session.pps_thread.devicename = "/dev/pps0";
- #endif /* MAGIC_HAT_GPS && MAGIC_LINK_GPS */
+ if (strcmp(session.pps_thread.devicename, MAGIC_HAT_GPS) == 0
+ || strcmp(session.pps_thread.devicename, MAGIC_LINK_GPS) == 0) {
+ char *first_pps = pps_get_first();
+ if (access(first_pps, R_OK | W_OK) == 0)
+ session.pps_thread.devicename = first_pps;
+ }
+ #endif /* MAGIC_HAT_ENABLE */
pps_thread_activate(&session.pps_thread);
}
#endif /* PPS_ENABLE */