[Git][NTPsec/ntpsec][master] gpsd driver: add support for refclock path option.
Gary E. Miller
gitlab at mg.gitlab.com
Wed Feb 8 01:38:30 UTC 2017
Gary E. Miller pushed to branch master at NTPsec / ntpsec
Commits:
63694d4c by Gary E. Miller at 2017-02-07T17:37:37-08:00
gpsd driver: add support for refclock path option.
- - - - -
2 changed files:
- docs/driver_gpsd.txt
- ntpd/refclock_gpsd.c
Changes:
=====================================
docs/driver_gpsd.txt
=====================================
--- a/docs/driver_gpsd.txt
+++ b/docs/driver_gpsd.txt
@@ -223,7 +223,7 @@ since the last poll.
+mode+::
Synonym for subtype, retained for backward compatibility.
+path+ 'filename'::
- Not used by this driver.
+ Overrides the default device path.
+ppspath+ 'filename'::
Not used by this driver.
+baud+ 'number'::
@@ -248,6 +248,7 @@ control loop. You do not want to use sloppy data for that.
----------------------------------------------------------------------------
refclock gpsd mode 2
+refclock gpsd mode 2 path /dev/tty.usbserial
----------------------------------------------------------------------------
This is configured for the experimental automatic mode.
=====================================
ntpd/refclock_gpsd.c
=====================================
--- a/ntpd/refclock_gpsd.c
+++ b/ntpd/refclock_gpsd.c
@@ -206,7 +206,7 @@ typedef struct addrinfo addrinfoT;
* We use the same device name scheme as does the NMEA driver; since
* GPSD supports the same links, we can select devices by a fixed name.
*/
-static const char * s_dev_stem = "/dev/gps";
+#define DEVICE "/dev/gps%u" /* GPS serial device */
/* =====================================================================
* forward declarations for transfer vector and the vector itself
@@ -254,7 +254,7 @@ struct gpsd_unit {
int unit;
int mode;
char *logname; /* cached name for log/print */
- char * device; /* device name of unit */
+ char *device; /* device name of unit */
/* current line protocol version */
uint32_t proto_version;
@@ -478,6 +478,7 @@ gpsd_start(
gpsd_unitT ** uscan = &s_clock_units;
struct stat sb;
+ int ret;
/* check if we can proceed at all or if init failed */
if ( ! gpsd_init_check())
@@ -506,8 +507,14 @@ gpsd_start(
* practicable, we will have to read the symlink, if
* any, so we can get the true device file.)
*/
- if (-1 == myasprintf(&up->device, "%s%u",
- s_dev_stem, up->unit)) {
+ if ( peer->path ) {
+ /* use the ntp.conf path name */
+ ret = myasprintf(&up->device, "%s", peer->path);
+ } else {
+ ret = myasprintf(&up->device, DEVICE, up->unit);
+ }
+ if (-1 == ret ) {
+ /* more likely out of RAM */
msyslog(LOG_ERR, "%s: clock device name too long",
up->logname);
goto dev_fail;
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/commit/63694d4cdc242fca7641539002029bee090d2a60
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ntpsec.org/pipermail/vc/attachments/20170208/5f9fd1bd/attachment.html>
More information about the vc
mailing list