[LinuxPPS] 2.6.22.1 x86_64 + ntp-4.2.4p3 + gpsclock
Udo van den Heuvel
udovdh at xs4all.nl
Sun Aug 5 14:37:48 CEST 2007
Udo van den Heuvel wrote:
> I see. (after checking out the ATOM patch)
> I will have a look and give it a try.
I found that the atom patch uses time_pps_findsource.
I made the attached patch to use time_pps_findpath.
So far one problem is left, I get the error below that the old atom
patch does not give.
What error did I make?
refclock_atom.c: In function âatom_ppsapiâ:
refclock_atom.c:319: error: âPPS_API_VERS_1â undeclared (first use in
this function)
refclock_atom.c:319: error: (Each undeclared identifier is reported only
once
refclock_atom.c:319: error: for each function it appears in.)
make[1]: *** [refclock_atom.o] Error 1
Please let me know.
Thanks,
Udo
-------------- next part --------------
--- refclock_atom.c.origineel 2007-08-05 13:27:45.000000000 +0200
+++ refclock_atom.c 2007-08-05 14:07:40.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 */
@@ -138,6 +140,7 @@
noentry, /* buginfo (not used) */
NOFLAGS /* not used */
};
+
#endif /* HAVE_PPPSAPI */
@@ -155,6 +158,11 @@
register struct ppsunit *up;
char device[80];
int mode;
+#ifdef PPS_HAVE_FINDPATH
+ char id[LENPPS] = "",
+ path[LENPPS]; //,
+// link[LENPPS] = "/dev/gps0"; /* just a default device */
+#endif /* PPS_HAVE_FINDPATH */
#endif /* HAVE_PPSAPI */
/*
@@ -176,21 +184,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) {
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 +246,18 @@
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 */
+ if (up->handle_created) {
+#endif /* PPS_HAVE_FINDPATH */
time_pps_destroy(up->handle);
+#ifdef PPS_HAVE_FINDPATH
+ up->handle_created = 0;
+ }
+#endif
#endif /* HAVE_PPSAPI */
if (pps_peer == peer)
pps_peer = NULL;
More information about the LinuxPPS
mailing list