From f8f474ed00294d943fe04b7bbd83ca3a9f6580f9 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Mon, 25 Apr 2016 17:09:32 -0400 Subject: Autoconfiguration kluge for Raspberry Pi. When a serial device to be opened is /dev/ttyAMA0, and /dev/pps0 exists, and we have read-write access to it (which implies running as root), substitute /dev/pps0 for the device name in the thread context so we use KPPS. Should be safe because /dev/ttyAMA0 is so specific to the Raspberry Pi. --- gpsmon.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'gpsmon.c') diff --git a/gpsmon.c b/gpsmon.c index c3eb3bd5..8a35138e 100644 --- a/gpsmon.c +++ b/gpsmon.c @@ -1296,6 +1296,14 @@ 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; + /* + * The Raspberry Pi kludge. If we're using /dev/ttyAMA0, + * and there is a static /dev/pps0, and we have access because + * we're root, assume we want to use KPPS. + */ + if (strcmp(session.pps_thread.devicename, "/dev/ttyAMA0") == 0 + && access("/dev/pps0", R_OK | W_OK) == 0) + session.pps_thread.devicename = "/dev/pps0"; pps_thread_activate(&session.pps_thread); } #endif /* PPS_ENABLE */ -- cgit v1.2.1