[LinuxPPS] Re: [Bug 610] Generic NMEA GPS Receiver driver w/ PPS expects PPS after NMEA data

Udo van den Heuvel udovdh at xs4all.nl
Sun Oct 28 10:01:15 CET 2007


Udo van den Heuvel wrote:
> Frank Kardel via the NTP Bugzilla wrote:
>> So I suggest:
>>   - test if you can open /dev/gpsppsX and to a pps_create first
>>     - if that succeeds use it else
>>     - try the pps_create on the master device
>>     that way you can overrule the master device by *configuring* the
>>     pps device in the file system.
> 
> So first open /dev/gpspps0 to get PPS there
> 	- if it fails, use /dev/gps0 next
> 	- if it succeeds get PPS
> Then open /dev/gps0 to get NMEA and *optionally* PPS
> 
> 
> Is this the right approach?

So I coded:

        /*
         * Initialize miscellaneous variables
         */
        peer->precision = PRECISION;
        pp->clockdesc = DESCRIPTION;
        memcpy((char *)&pp->refid, REFID, 4);
        up->pollcnt = 2;
        gps_send(pp->io.fd,"$PMOTG,RMC,0000*1D\r\n", peer);

#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);
        (void) sprintf(device, DEVICEPPS, unit);
        msyslog(LOG_ERR, "refclock_nmea: try \"%s\" for PPS", device);
        fd = open(device, O_RDWR);
        if (fd < 0) {
                /* Try the /dev/gps device for PPS */
                (void) sprintf(device, DEVICE, unit);
                msyslog(LOG_ERR, "refclock_nmea: try GPS device \"%s\"
for PPS", device);
                if (time_pps_create(pp->io.fd, &up->handle) < 0)
                        goto pps_error;
        } else
        if (time_pps_create(fd, &up->handle) < 0) {
                if (time_pps_create(pp->io.fd, &up->handle) < 0)
                goto pps_error;
                else (void) sprintf(device, DEVICE, unit);
        }
        msyslog(LOG_INFO, "refclock_nmea: found PPS source \"%s\"", device);
        return(nmea_ppsapi(peer, 0, 0));
#else
        return (1);
#endif /* HAVE_PPSAPI */

pps_error:
        /* 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);
}

/*
 * nmea_shutdown - shut down a GPS clock
 */


Please comment.
I open /dev/gps0 for NMEA.
Then try to open /dev/gpspps0 and try for PPS. (Frank's request)
If the open fails we try /dev/gps0 for PPS.
If the open of /dev/gpspps0 succeeds but the pps_time_create fails we
try /dev/gps0 for PPS.

Question: /dev/gpspps0 can be a link o /dev/pps0?



More information about the LinuxPPS mailing list