[ntp:questions] how to write a reference clock driver

Juergen Kosel juergen.kosel at freenet.de
Wed Dec 17 13:01:14 UTC 2008


Hello,

Harlan Stenn schrieb:
>>>> In article <4944eab4$0$12693$9b622d9e at news.freenet.de>, Juergen Kosel <juergen.kosel at freenet.de> writes:
> 
> Juergen> Hello, Greg Dowd schrieb:
>>> I'm not quite sure what you mean.  A reference clock doesn't compute an
>>> offset, it acquires, formats and returns a time value from an external
>>> source.  NTP takes care of the rest.
> 
> Juergen> ntpd reads the time of a reference clock with a reference clock
> Juergen> driver.  My problem was, that I didn't know from the manual what
> Juergen> need to be done with the time from the reference clock. Especially
> Juergen> when it is in a differnet format than of the other reference
> Juergen> clocks.
> 
> Juergen> But finally I succeeded by calculating the difference between
> Juergen> refence clock time - system clock time and using the SAMPLE() macro
> Juergen> to insert this value into the the right data structure entry of
> Juergen> ntpd.
> 
> 
> Juergen,
> 
> Most refclock drives do not do it the way you describe.
> 
> They take the time from the reflock along with the system timestamp (with
> the intent to get the system timestamp as close as possible to the moment
> the refclock timestamp is obtained), build the contents of the struct
> refclockproc, and call refclock_process().
> 

Those driver give the time in the format month, day, hour, minute,...
Function refclock_process() converts this time into seconds and
nanosecond. But my reference clock already delivers the time in this format.
After the conversation refclock_process() calls internally the SAMPLE()
macro. Since computing time is a concern, I believe it is the better way
to use directly the SAMPLE() macro.


Greetings
	Juergen




More information about the questions mailing list