[LinuxPPS] FW: ntp-4.2.4p0 + ntpd_nmea.patch

Rodolfo Giometti giometti at enneenne.com
Sun Aug 19 22:12:25 CEST 2007


On Sun, Aug 19, 2007 at 06:31:17PM +0200, Udo van den Heuvel wrote:

> I am wrestling with:
> How to deal with io_closeclock in the case of two fd's?
> (when a NMEA device has two devices open for NMEA and PPS)
> 
> (this is needed to handle all cases of 1 and two devices with NMEA and PPS)

I don't understand your problem... looking at file refclock_nmea.c I
see only this io_closeclock() occurrence:

   /*
    * nmea_shutdown - shut down a GPS clock
    */
   static void
   nmea_shutdown(
           int unit,
           struct peer *peer
           )
   {
           register struct nmeaunit *up;
           struct refclockproc *pp;

           pp = peer->procptr;
           up = (struct nmeaunit *)pp->unitptr;
   #ifdef HAVE_PPSAPI
           if (up->handle != 0)
                   time_pps_destroy(up->handle);
   #endif /* HAVE_PPSAPI */
           io_closeclock(&pp->io);
           free(up);
   }

and it doesn't touch up->handle at all.

However I suggest to you to do something like this during open phase:

   #ifdef HAVE_PPSAPI
           /*
            * Start the PPSAPI interface if it is there. Default to use
            * the assert edge and do not enable the kernel hardpps.
            */
           if (time_pps_create(fd, &up->handle) < 0) {
	   	   /* Try the alternare PPS device */
		   (void) sprintf(device, DEVICEPPS, unit);

		   fd = open(device, O_RDWR);
		   if (fd < 0)
                           goto pps_error;

		   if (time_pps_create(fd, &up->handle) < 0) 
			   goto	pps_error;
           }
           return(nmea_ppsapi(peer, 0, 0));

pps_error:
           /* No luck, no PPS unit available! */
           up->handle = 0;
           msyslog(LOG_ERR,
               "refclock_nmea: alternate PPS device %s fail : %m", device);
           return (1);

   #else
           return (1);
   #endif /* HAVE_PPSAPI */

Please, check the code, I just wrote it without reveiwing. :)

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