[ntp:hackers] linuxPPS for linux 2.6

Danny Mayer mayer at ntp.isc.org
Wed Jan 11 13:53:50 UTC 2006


Rodolfo Giometti wrote:
> Hello,
> 
> 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-2.6.14.5).
> 
>    http://ftp.enneenne.com/pub/projects/linuxpps/contrib/linux-2.6/ntp-pps-2.6.15-rc7.diff   
> 
> 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:
> 
>    http://ftp.enneenne.com/pub/projects/linuxpps/test/
> 
> 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
> PPS_HAVE_FINDSOURCE define).
> 
> 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;
> 	  		msyslog(LOG_ERR,
> 	  			"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
> time_pps_destroy().
> 
> 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. :)
> 
> Ciao,
> 
> Rodolfo
> 

Could you add this to the Wiki pages at http://ntp.isc.org/ so that
people won't have to wade through the mailing list to find the information?

Danny


More information about the hackers mailing list