[LinuxPPS] 2.6.22.1 x86_64 + ntp-4.2.4p3 + gpsclock
Udo van den Heuvel
udovdh at xs4all.nl
Tue Aug 7 14:41:29 CEST 2007
Udo van den Heuvel wrote:
> Udo van den Heuvel wrote:
> does it mean that atom_start (in refclock_atom.c) is completed without
> issues?
Yes/no.
I went over the old atom.patch and found some other changes in some
logic. I copied those and now ntpd appears to work with pps again using
the time_pps_findpath function.
Attached is the current patch.
Please have a look at this new patch *AND* the old patch at
http://ftp.enneenne.com/pub/misc/linuxpps/refclocks/atom/atom.patch to
see if I made the right changes and/or copied the right stuff.
Thanks,
Udo
-------------- next part --------------
--- 1/ntpd/refclock_atom.c 2007-08-07 14:22:58.000000000 +0200
+++ 2/ntpd/refclock_atom.c 2007-08-07 14:30:03.000000000 +0200
@@ -79,6 +79,7 @@
*/
#ifdef HAVE_PPSAPI
#define DEVICE "/dev/pps%d" /* device name and unit */
+#define LENPPS PPS_MAX_NAME_LEN
#endif /* HAVE_PPSAPI */
#define PRECISION (-20) /* precision assumed (about 1 us) */
@@ -99,6 +100,7 @@
pps_params_t pps_params; /* pps parameters */
pps_info_t pps_info; /* last pps data */
pps_handle_t handle; /* pps handlebars */
+ int handle_created; /* pps handle created flag */
};
#endif /* HAVE_PPSAPI */
@@ -155,6 +157,10 @@
register struct ppsunit *up;
char device[80];
int mode;
+#ifdef PPS_HAVE_FINDPATH
+ char id[LENPPS] = "",
+ path[LENPPS];
+#endif /* PPS_HAVE_FINDPATH */
#endif /* HAVE_PPSAPI */
/*
@@ -176,21 +182,37 @@
* not necessarily the port used for the associated radio.
*/
sprintf(device, DEVICE, unit);
+#ifdef PPS_HAVE_FINDPATH
+ /* Get the PPS source's real name */
+ time_pps_readlink(device, sizeof(device), path, LENPPS);
+
+ /* Try to find the source */
+ up->fddev = time_pps_findpath(path, LENPPS, id, LENPPS);
+ if (up->fddev < 0) {
+ msyslog(LOG_ERR, "refclock_atom: cannot find PPS path \"%s\" in the system", path);
+ return (0);
+ }
+ msyslog(LOG_INFO, "refclock_atom: found PPS source \"%s\" at id #%d on \"%s\"", path, up->fddev, id);
+#else /* PPS_HAVE_FINDPATH */
+
up->fddev = open(device, O_RDWR, 0777);
- if (up->fddev <= 0) {
+ if (up->fddev < 0) {
msyslog(LOG_ERR,
"refclock_atom: %s: %m", device);
return (0);
}
+#endif /* PPS_HAVE_FINDPATH */
/*
* Light off the PPSAPI interface.
*/
if (time_pps_create(up->fddev, &up->handle) < 0) {
+ up->handle_created = 0;
msyslog(LOG_ERR,
"refclock_atom: time_pps_create failed: %m");
return (0);
}
+ up->handle_created = ~0;
/*
* If the mode is nonzero, use that for the time_pps_setparams()
@@ -222,10 +244,14 @@
pp = peer->procptr;
up = (struct ppsunit *)pp->unitptr;
#ifdef HAVE_PPSAPI
+#ifndef PPS_HAVE_FINDPATH
if (up->fddev > 0)
close(up->fddev);
if (up->handle != 0)
+#else /* PPS_HAVE_FINDPATH */
time_pps_destroy(up->handle);
+ up->handle_created = 0;
+#endif
#endif /* HAVE_PPSAPI */
if (pps_peer == peer)
pps_peer = NULL;
@@ -275,8 +301,13 @@
pp = peer->procptr;
up = (struct ppsunit *)pp->unitptr;
+#ifdef PPS_HAVE_FINDSOURCE
+ if (up->fddev < 0)
+ return 0;
+#else
if (up->handle == 0)
return (0);
+#endif
if (time_pps_getcap(up->handle, &capability) < 0) {
msyslog(LOG_ERR,
@@ -284,7 +315,7 @@
return (0);
}
memset(&up->pps_params, 0, sizeof(pps_params_t));
- up->pps_params.api_version = PPS_API_VERS_1;
+ up->pps_params.api_version = PPS_API_VERS;
up->pps_params.mode = mode | PPS_TSFMT_TSPEC;
if (time_pps_setparams(up->handle, &up->pps_params) < 0) {
msyslog(LOG_ERR,
@@ -345,8 +376,13 @@
*/
pp = peer->procptr;
up = (struct ppsunit *)pp->unitptr;
+#ifdef PPS_HAVE_FINDSOURCE
+ if (up->fddev < 0)
+ return;
+#else
if (up->handle == 0)
return;
+#endif
timeout.tv_sec = 0;
timeout.tv_nsec = 0;
More information about the LinuxPPS
mailing list