[LinuxPPS] ntp 'bugs'

Udo van den Heuvel udovdh at xs4all.nl
Sun Jun 29 12:20:07 CEST 2008


Rodolfo Giometti wrote:
> I suppose file descriptor pp->io.fd is related to the serial line so
> in the above time_pps_create() the ioctl(source, PPS_CHECK) fails and
> the ldisc is changed returing error. This causes a an
> open("/dev/pps{N}", ...) and a new time_pps_create() on the PPS
> device.
> 
> Is that right?

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.



More information about the LinuxPPS mailing list