[LinuxPPS] LinuxPPS 5.0.0-rc1
Rodolfo Giometti
giometti at enneenne.com
Mon Aug 13 15:46:10 CEST 2007
On Fri, Aug 10, 2007 at 05:44:21PM +0200, Udo van den Heuvel wrote:
> Rodolfo Giometti wrote:
> > On Fri, Aug 10, 2007 at 04:42:03PM +0200, Udo van den Heuvel wrote:
> >> Please review and give feedback so we all can learn.
> >>
> >
> >> --- refclock_nmea.c.origineel 2007-08-10 16:16:16.000000000 +0200
> >> +++ refclock_nmea.c 2007-08-10 16:38:01.000000000 +0200
> (...)
> >> @@ -91,6 +93,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 */
> >
> > Now this is not needed anymore since pps_handle_t is becomed an "int"
> > again... however this is not an error, but your patch may result
> > smaller if you don't use it! :)
>
> pps_handle_t is not in my patch, but I will change it to int.
Sorry, was my fault... I mean that you shouldn't use "handle_created"
anymore since "pps_handle_t" is becomed an "int" so you can set handle
to "-1" in case of error.
> >> /*
> >> * Open serial port. Use CLK line discipline, if available.
> >> */
> >> - (void)sprintf(device, DEVICE, unit);
> >> + (void)sprintf(gpsdevice, GPSDEVICE, unit);
> >> + (void)sprintf(ppsdevice, PPSDEVICE, unit);
> >>
> >> - fd = refclock_open(device, SPEED232, LDISC_CLK);
> >> - if (fd <= 0) {
> >> + gps_fd = refclock_open(gpsdevice, SPEED232, LDISC_CLK);
> >> + pps_fd = refclock_open(ppsdevice, SPEED232, LDISC_CLK);
> >> + if (gps_fd <= 0) {
> >
> > Make attention here! Refclock should work in both ways:
> >
> > 1) the GPS source and PPS source are the same device, or
> >
> > 2) the GPS source and PPS source are __different__ devices.
> >
> > Your code assumes case 2 only. I suggest you in using bit 7 as PARSE
> > refclock in order to know what to do (please see my preovious letter
> > on this topic for a code example).
>
> This is what puzzles me. As in the wiki you write:
>
> (under Modifing a reference clock to work with LinuxPPS)
>
> So your programs should check if the GPS data source (the serial port
> for instance) is a PPS source too, otherwise they should provide the
> possibility to open another device as PPS source.
>
> So I just wait for the 4th octet of the fake IP that ntpd uses?
> I browsed the parse reflock source and I found in ntp_request.h there is
> some definition of the mode parameter, but how do I fill this struct?
Please, look as PARSE does:
/*
* PPS via PPSAPI
*/
#if defined(HAVE_PPSAPI)
parse->hardppsstate = PARSE_HARDPPS_DISABLE;
if (CLK_PPS(parse->peer))
{
if (time_pps_create(parse->ppsfd, &parse->ppshandle) < 0)
{
msyslog(LOG_NOTICE, "PARSE receiver #%d: parse_start: could not set up PPS: %m", CLK_UNIT(parse->peer));
}
else
{
parse_ppsapi(parse);
}
}
#endif
you should do something similar, or you can just try the PPS source
anyway, for example:
gps_fd = open(gpsdevice, ...);
#if defined(HAVE_PPSAPI)
handle = -1;
pps_fd = -1;
if (time_pps_create(gps_fd, &handle) {
/* use handle */
} else {
/* try "ppsdevice" */
pps_fd = open(ppsdevice, ...);
if (time_pps_create(pps_fd, &handle) {
/* use handle */
else {
/* error: no valid PPS sources! *
}
}
#endif
...
/* At the end we should close all opened handlers */
if (pps_fd >= 0)
time_pps_destroy(&handle)
if (pps_fd >= 0)
close(pps_fd);
close(gps_fd);
Ciao,
Rodolfo
--
GNU/Linux Solutions e-mail: giometti at enneenne.com
Linux Device Driver giometti at gnudd.com
Embedded Systems giometti at linux.it
UNIX programming phone: +39 349 2432127
More information about the LinuxPPS
mailing list