summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFred Wright <fw@fwright.net>2016-12-22 17:32:45 -0800
committerFred Wright <fw@fwright.net>2016-12-22 17:32:45 -0800
commit79c69b2b12e5f8ee3aa3f50b8886a0a7bbdd73f7 (patch)
tree4144ed2bf859363b996af60e1ae3dcaec69da875
parentd1fd9ad44f320235b4d449988570ab5633f21bab (diff)
downloadgpsd-79c69b2b12e5f8ee3aa3f50b8886a0a7bbdd73f7.tar.gz
Makes MAGIC_HAT kludge optional.
This adds a build option called 'magic_hat', and makes the code for MAGIC_HAT_GPS and MAGIC_LINK_GPS conditional on it. It currently defaults to True on Linux and False otherwise. It's meaningless on non-Linux platforms, though at present there are no conditionally-present options, so this one is also present on all platforms. TESTED: Tested on a Beaglebone Black with suitable symlinks added (and running a kernel with PPS_CLIENT_KTIMER turned off. Verified that the kludge behaves as intended when enabled, and is inoperative when disabled.
-rw-r--r--SConstruct5
-rw-r--r--gpsmon.c6
-rw-r--r--timehint.c6
3 files changed, 12 insertions, 5 deletions
diff --git a/SConstruct b/SConstruct
index 1efdefba..83f0e6f0 100644
--- a/SConstruct
+++ b/SConstruct
@@ -174,6 +174,8 @@ boolopts = (
("leapfetch", True, "fetch up-to-date data on leap seconds."),
("minimal", False, "turn off every option not set on the command line"),
("timeservice", False, "time-service configuration"),
+ ("magic_hat", sys.platform.startswith('linux'),
+ "special Linux PPS hack for Raspberry Pi et al"),
("xgps", True, "include xgps and xgpsspeed."),
# Test control
("slow", False, "run tests with realistic (slow) delays"),
@@ -845,7 +847,8 @@ else:
env["pps"] = False
# Simplifies life on hackerboards like the Raspberry Pi
- confdefs.append('''\
+ if env['magic_hat']:
+ confdefs.append('''\
/* Magic device which, if present, means to grab a static /dev/pps0 for KPPS */
#define MAGIC_HAT_GPS "/dev/ttyAMA0"
/* Generic device which, if present, means to grab a static /dev/pps0 for KPPS */
diff --git a/gpsmon.c b/gpsmon.c
index 724e4cc4..9a02ef62 100644
--- a/gpsmon.c
+++ b/gpsmon.c
@@ -1318,6 +1318,7 @@ int main(int argc, char **argv)
/* this guard suppresses a warning on Bluetooth devices */
if (session.sourcetype == source_rs232 || session.sourcetype == source_usb) {
session.pps_thread.report_hook = pps_report;
+ #ifdef MAGIC_HAT_ENABLE
/*
* The HAT kludge. If we're using the HAT GPS on a
* Raspberry Pi or a workalike like the ODROIDC2, and
@@ -1326,8 +1327,9 @@ int main(int argc, char **argv)
*/
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";
+ && access("/dev/pps0", R_OK | W_OK) == 0)
+ session.pps_thread.devicename = "/dev/pps0";
+ #endif /* MAGIC_HAT_GPS && MAGIC_LINK_GPS */
pps_thread_activate(&session.pps_thread);
}
#endif /* PPS_ENABLE */
diff --git a/timehint.c b/timehint.c
index 3ca03120..fc5d397a 100644
--- a/timehint.c
+++ b/timehint.c
@@ -459,6 +459,7 @@ void ntpshm_link_activate(struct gps_device_t *session)
} else {
init_hook(session);
session->pps_thread.report_hook = report_hook;
+ #ifdef MAGIC_HAT_ENABLE
/*
* The HAT kludge. If we're using the HAT GPS on a
* Raspberry Pi or a workalike like the ODROIDC2, and
@@ -467,8 +468,9 @@ void ntpshm_link_activate(struct gps_device_t *session)
*/
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";
+ && access("/dev/pps0", R_OK | W_OK) == 0)
+ session->pps_thread.devicename = "/dev/pps0";
+ #endif /* MAGIC_HAT_GPS && MAGIC_LINK_GPS */
pps_thread_activate(&session->pps_thread);
}
}