[email protected]
[Top] [All Lists]

linuxPPS for linux 2.6

Subject: linuxPPS for linux 2.6
From: Rodolfo Giometti
Date: Tue, 3 Jan 2006 15:10:24 GMT
Newsgroups: comp.protocols.time.ntp

some people start using my linuxPPS support on linux 2.6 so I decided
to make a patch against linux-2.6.15-rc7 (but it should complile also
with linux-


Please try it and report (possible) bugs. The patch currently support
the debug client «ktimer» and the patch for 8250 serial lines by
Sebastian Classen.

Here you can find the userland testing program:


I'd like also to send this patch to the main linux tree but before
doing it I'd like to know what are you thinking about the type
«pps_handle_t problem».

The RFC 2783 says that «"pps_handle_t" type is an opaque scalar type
used to represent a PPS source within the API».

In my implementation I intentionally want to separate the concept of
«file descriptor» to the concept of «PPS source» since some devices do
not have such association (some devices are directly connected to a
dedicated interrupt line). If our antenna is connected with a serial
line everything works well but if not we have no «filedes» to pass to
the function time_pps_create(). That's why I added a new function
time_pps_findsource() in order to find into the system a generic PPS
source (note that this function is protected by the

So, my opinion is that RFC 2783 _should_ say that «"pps_handle_t" type
is an opaque variable used to represent a PPS source within the API»
and programs _should_ not access directly to it due its «opacity».

Also the RFC 2783 does not say that programs should check the
pps_handle_t variable before calling the time_pps_* functions, since
each function should do this job internally.

Here, as example, some modification in order to make a refclock
working with my PPS support:

         +#ifdef PPS_HAVE_FINDSOURCE
         +      /* Try to find the source (by using "index = -1" we ask just 
for a
         +       * generic source) */
         +      fd = time_pps_findsource(-1, id, 40, path, 40);
         +      if (fd < 0) {
         +              msyslog(LOG_ERR, "refclock: no available PPS source in 
the system");
         +              return (1);
         +      }
         +      msyslog(LOG_INFO, "refclock: found PPS source #%d \"%s\" on 
\"%s\"", fd, path, id);
         +#endif   /* PPS_HAVE_FINDSOURCE */
                if (time_pps_create(fd, &pps_handle) < 0) {
         -              pps_handle = 0;
                                "refclock: time_pps_create failed: %m");

In this manner «fd» is not a file descriptor but it is a PPS source
ID. In older program, by using the PPS_HAVE_FINDSOURCE define,
everything should continue working well.
          #ifdef HAVE_PPSAPI
         -      if (pps_handle) {
         -              time_pps_destroy(pps_handle);
         -              pps_handle = 0;
         -      }
         +      time_pps_destroy(pps_handle);
          #endif /* HAVE_PPSAPI */
Here we do not need checking the «pps_handle» status before calling

Please, let me know what are you thinking about it, so I can do needed
modifications and then send the final job to the linux main tree. :)




GNU/Linux Solutions                  e-mail:    [email protected]
Linux Device Driver                             [email protected]
Embedded Systems                                [email protected]
UNIX programming                     phone:     +39 349 2432127
questions mailing list
[email protected]
<Prev in Thread] Current Thread [Next in Thread>
  • linuxPPS for linux 2.6, Rodolfo Giometti <=