[LinuxPPS] ntp 'bugs'

Rodolfo Giometti giometti at enneenne.com
Sun Jun 29 12:36:27 CEST 2008


On Sun, Jun 29, 2008 at 12:20:07PM +0200, Udo van den Heuvel wrote:

> Following your line of thought, the nmea reflock code could then be like
> this: (untested)
> 
> #ifdef HAVE_PPSAPI
>         /*
>          * Start the PPSAPI interface if it is there. Default to use
>          * the assert edge and do not enable the kernel hardpps.
>          */
>         msyslog(LOG_ERR, "refclock_nmea: found GPS source \"%s\"", device);
>         if (time_pps_create(pp->io.fd, &up->handle) == 0) {
>                 msyslog(LOG_INFO, "refclock_nmea: found PPS source
> \"%s\"", device);
>                 return(nmea_ppsapi(peer, 0, 0)); }
>         else {
>                /* Try the alternate PPS device */
>                (void) sprintf(device, DEVICEPPS, unit);
>                fd = open(device, O_RDWR);
>                 if (fd > 0) {   /* /dev/gpspps0 exists */
>                         msyslog(LOG_ERR, "refclock_nmea: try \"%s\" for
> PPS", device);
>                         if (time_pps_create(fd, &up->handle) == 0) {
>                                 msyslog(LOG_INFO, "refclock_nmea: found
> PPS source \"%s\"", device);
>                                 return(nmea_ppsapi(peer, 0, 0));
>                         }
>                         else {
>                                 close(fd);
>                         }
> 
>                 } else { /* retry because of ldisc principle */
>                         if (time_pps_create(pp->io.fd, &up->handle) == 0) {
>                                 (void) sprintf(device, DEVICE, unit);
>                                 msyslog(LOG_INFO, "refclock_nmea: found
> PPS source \"%s\"", device);
>                                 return(nmea_ppsapi(peer, 0, 0)); }
>                 }
>         }
> 
>         /* No luck, no PPS unit available! */
>         up->handle = -1;
>         msyslog(LOG_ERR, "refclock_nmea: no PPS devices found at "
> DEVICE " nor "
>                 DEVICEPPS ": %m", unit, unit);
>         return (1);
> #else
>         return (1);
> #endif /* HAVE_PPSAPI */
> 
> 
> First we check for pps on the NMEA device which in our case will fail
> but set the right line discipline so that the PPS device is created.
> Then we check for the PPS device which will give us pps.
> When the PPS device is not existing or if there is no pps we try the
> NMEA device once more (yes, stuff might have changed due to the line
> discipline thing; it is a matter of principle) and exit.

I don't understand why, after first time_pps_create(pp->io.fd, ...)
calling, you need to more time_pps_create(). O_o

Just defining as main PPS device /dev/ttyS{N} and as alternate PPS
device /dev/pps{N} and by using my proposed code, everything should
work ok.

Ciao,

Rodolfo

-- 

GNU/Linux Solutions                  e-mail: giometti at enneenne.com
Linux Device Driver                          giometti at linux.it
Embedded Systems                     phone:  +39 349 2432127
UNIX programming                     skype:  rodolfo.giometti



More information about the LinuxPPS mailing list