[Git][NTPsec/ntpsec][master] refclock_nmea: report device actually opened.

Gary E. Miller gitlab at mg.gitlab.com
Fri Sep 15 01:55:29 UTC 2017


Gary E. Miller pushed to branch master at NTPsec / ntpsec


Commits:
6e993dec by Gary E. Miller at 2017-09-15T01:55:17Z
refclock_nmea: report device actually opened.

Partially addresses issue #357.  Not logging the NMEA device actually
opened.

- - - - -


1 changed file:

- ntpd/refclock_nmea.c


Changes:

=====================================
ntpd/refclock_nmea.c
=====================================
--- a/ntpd/refclock_nmea.c
+++ b/ntpd/refclock_nmea.c
@@ -477,20 +477,24 @@ nmea_start(
 	memcpy(&pp->refid, REFID, REFIDLEN);
 	peer->sstclktype = CTL_SST_TS_UHF;
 
-	/* Open serial port. Use CLK line discipline, if available. */
-        rcode = snprintf(device, sizeof(device), DEVICE, unit);
-        if ( 0 > rcode ) {
-            pp->io.fd = -1;
-        } else {
-            pp->io.fd = refclock_open(peer->cfg.path ? peer->cfg.path : device,
-                                      baudrate,
-                                      LDISC_CLK);
+	if ( !peer->cfg.path ) {
+            /* build a path */
+	    rcode = snprintf(device, sizeof(device), DEVICE, unit);
+	    if ( 0 <= rcode ) {
+		peer->cfg.path = estrdup( device );
+            } else {
+		pp->io.fd = -1;
+		return false;  /* huh? */
+            }
         }
-	if (-1 == pp->io.fd)
+	/* Open serial port. Use CLK line discipline, if available. */
+	pp->io.fd = refclock_open(device, baudrate, LDISC_CLK);
+
+	if (0 > pp->io.fd)
 		return false;
 
 	LOGIF(CLOCKINFO, (LOG_NOTICE, "%s serial %s open at %s bps",
-	      refclock_name(peer), device, baudtext));
+	      refclock_name(peer), peer->cfg.path, baudtext));
 
 	/* succeed if this clock can be added */
 	return io_addclock(&pp->io) != 0;



View it on GitLab: https://gitlab.com/NTPsec/ntpsec/commit/6e993dec8e162f6b50c01560d5c63af76f0babb2

---
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/commit/6e993dec8e162f6b50c01560d5c63af76f0babb2
You're receiving this email because of your account on gitlab.com.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ntpsec.org/pipermail/vc/attachments/20170915/97eef316/attachment.html>


More information about the vc mailing list