[LinuxPPS] 2.6.22.1 x86_64 + ntp-4.2.4p3 + gpsclock
Udo van den Heuvel
udovdh at xs4all.nl
Sun Aug 5 21:06:29 CEST 2007
Udo van den Heuvel wrote:
>>> 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
>> This is due the fact I cannot define PPS_API_VERS_1... just turn
>> PPS_API_VERS_1 into PPS_API_VERS_2 and everything should continue to
>> work.
>
> But why is this error not there when I use the current ('old') atom patch?
Pending the answer to this question, here is my latest atom patch.
I did not yet test it but it compiles OK and was made following the ways
of the NMEA patch.
Please give the patch a review.
Thanks,
Udo
-------------- next part --------------
--- refclock_atom.c.orgg 2006-06-06 22:16:48.000000000 +0200
+++ refclock_atom.c 2007-08-05 21:05:05.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) {
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,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;
@@ -284,7 +314,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_2;
up->pps_params.mode = mode | PPS_TSFMT_TSPEC;
if (time_pps_setparams(up->handle, &up->pps_params) < 0) {
msyslog(LOG_ERR,
More information about the LinuxPPS
mailing list