Skip to content

Commit

Permalink
Makes MAGIC_HAT kludge optional.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
fhgwright committed Dec 23, 2016
1 parent d1fd9ad commit 79c69b2
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
5 changes: 4 additions & 1 deletion SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand Down Expand Up @@ -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 */
Expand Down
6 changes: 4 additions & 2 deletions gpsmon.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 */
Expand Down
6 changes: 4 additions & 2 deletions timehint.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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);
}
}
Expand Down

0 comments on commit 79c69b2

Please sign in to comment.