[LinuxPPS] ntp 'bugs'

Rodolfo Giometti giometti at enneenne.com
Sun Jun 29 11:29:44 CEST 2008


On Sat, Jun 28, 2008 at 06:35:10PM +0200, Udo van den Heuvel wrote:
> Rodolfo Giometti wrote:
> >         /* First we check if current device is a PPS valid PPS one...
> >          */
> >         ret = ioctl(source, PPS_CHECK);
> >         if (ret == 0) {
> > 		/* Got it! Since in LinuxPPS there are no differences
> > 		 * between a "PPS source" and a "PPS handle", we
> > 		 * simply return the same value.
> > 		 */
> > 		*handle = source;
> > 
> > 		return 0;
> > 	}
> > 
> > 	/* Before exiting an error we have to verify if we can
> > 	 * change the line discipline for the current device in
> > 	 * case it's a serial one.
> > 	 */
> > 	ldisc = N_PPS;
> > 	(void) ioctl(pp->io.fd, TIOCSETD, &ldisc);
> > 
> > 	/* The we return error, so caller should try the alternate
> > 	 * device.
> > 	 */
> >         errno = EOPNOTSUPP;
> >         return -1;
> > }
> 
> Hmm. I had to look at the code in refclock_nmea...
> Does the ldisc change work on the pps device so that it effects the
> `connected` serial line?
> This because the first time_pps_create in refclock_nmea is on the pps
> device. Only when that fails we do a time_pps_create on the serial line
> itself as a fallback.

But usually you have the serial line as the main PPS device and
/dev/pps{N} as altrenate one. Is that rigth?

> Please enlighten us on the flow of the change in time_pps_create and the
> correlation with e.g. the code in refclock_nmea.

Here the refclock nmea code:

+       msyslog(LOG_ERR, "refclock_nmea: found GPS source \"%s\"", device);
+       if (time_pps_create(pp->io.fd, &up->handle) < 0) {
+               /* Try the alternate PPS device */
+                (void) sprintf(device, DEVICEPPS, unit);
+               msyslog(LOG_ERR, "refclock_nmea: try alternate PPS device \"%s\"", device);
+                fd = open(device, O_RDWR);
+                if (fd < 0)
+                       goto pps_error;
+               if (time_pps_create(fd, &up->handle) < 0)
+                               goto pps_error;
        }
+       else (void) sprintf(device, DEVICE, unit); /* just rebuild device's name */

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?

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