[LinuxPPS] [RFC] time_pps_createbyname()

Rodolfo Giometti giometti at enneenne.com
Wed Jul 18 15:19:05 CEST 2007


Hello,

I'm looking at userland API and I think we should define it better...
I think we should force users to avoid using of time_pps_create() by
modifying it as follow:

   int time_pps_create(int source, pps_handle_t *handle)
   {
           errno = EINVAL;
           return -1;
   }

and adding a new and more appropriate function to obtain a PPS handle:

   int time_pps_createbyname(char *name, pps_handle_t *handle, int flags);

This doesn't mean that other PPS implementations cannot define
time_pps_create() but with the Linux one we _must_ avoid using it.

The field "flags" can be used to specify searching criteria. For
example:

   PPS_NAME	match "name" with PPS source's name
   PPS_PATH	match "name" with PPS source's path
   PPS_RANDOM	just return at least one PPS source if present
   etc.

So NTPD refclocks drivers can be easily modified as follow:

        /*
         * Start the PPSAPI interface if it is there. Default to use
         * the assert edge and do not enable the kernel hardpps.
	 */
#ifdef PPS_HAVE_CREATEBYNAME
	if (time_pps_createbyname(device, &up->handle, PPS_PATH) < 0) {
#else
        if (time_pps_create(fd, &up->handle) < 0) {
#endif
                up->handle = 0;
                msyslog(LOG_ERR,
                    "refclock_nmea: time_pps_create failed: %m");
                return (1);
        }
        return(nmea_ppsapi(peer, 0, 0));

Suggestions? :)

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