Re: [chrony-users] Automotive usage of chronyd

[ Thread Index | Date Index | More chrony.tuxfamily.org/chrony-users Archives ]


Olivier

The manual says:
"The format of messages sent over the socket is described in the refclock_sock.c file."

So, I propose looking there. :)

Tom

On 7 Apr 2015 11:04, Olivier Delbeke <olivier.delbeke@xxxxxxxxx> wrote:
Hi all,

I think I completely misunderstood what I have to send to chronyd. All my samples are still rejected.
The system's date/time is Jan 1, 1970, 00:18. Every second, I get the correct (UTC) time from the GPS sensor and send it to chronyd.
Here are my logs :
  1970-01-01T00:18:02Z refclock.c:267:(RCL_AddRefclock) refclock SOCK refid=SOC1 poll=4 dpoll=0 filter=64
  1970-01-01T00:18:08Z refclock.c:517:(valid_sample_time) SOC1 refclock sample not valid age=-1428391752.477614 tv=1428392841.000000
  1970-01-01T00:18:09Z refclock.c:517:(valid_sample_time) SOC1 refclock sample not valid age=-1428391752.941502 tv=1428392842.000000
  1970-01-01T00:18:10Z refclock.c:517:(valid_sample_time) SOC1 refclock sample not valid age=-1428391752.931989 tv=1428392843.000000

The tv values are what I send : it's the timestamp received from the GPS sensor, in local time (created using mktime()).

My chrony.conf :
   refclock SOCK /tmp/chrony.gps.sock
   makestep 1000 10

The code that fills the structure that I send to chronyd :
   chronydata.tv.tv_sec  = mktime(...);
   chronydata.tv.tv_usec = 0;
   chronydata.offset = 0.0;   // What should I store here ?
   chronydata.pulse = 0;   // What should I store here ?
   chronydata.leap = 0;   // What should I store here ?
   chronydata.magic = 0x534f434b;
   send(sockfd,&chronydata,sizeof(chronydata),0);

What is wrong there ? What should I store in offset, pulse and leap ?

Thank you and best regards,
Olivier


On Tue, Apr 7, 2015 at 9:39 AM, Miroslav Lichvar <mlichvar@xxxxxxxxxx> wrote:
On Sat, Apr 04, 2015 at 09:07:17AM +0200, Olivier Delbeke wrote:
> Two questions :
> 1. Can chronyd use non-precise references like a GPS sensor without PPS
> (+-200ms) or an RDS FM timestamp (+-100ms)?

Yes, but you may need to use the minsamples option to prevent chronyd
from dropping too many samples to improve the accuracy as these
sources tend to have large non-random offsets.

> 2. Can chronyd set the system time when it has not been initialized yet
> (Jan 1, 1970) ?

Yes, use the makestep directive in chrony.conf.

> I made a first test in a near worst-case scenario : system without RTC and
> without network, but with only a USB GPS sensor (without PPS). Time/date
> after boot is Jan 1, 1970, 00:00:00. I send the timestamps of the GPS
> sensor to chronyd (over a socket), but chronyd rejects them. Even if I use
> the first GPS timestamp to force the system time, the subsequent timestamps
> are still rejected by chronyd ("refclock sample not valid age=-0.41" from
> refclock.c - valid_sample_time())). What is the condition for a valid
> sample ? I can understand that samples are rejected, but the "< 0.0"
> conditions looks like the drift is only allowed in one direction. Is that
> right ?

It checks if the sample time is not from the future or too old.
Maybe you are setting the sample time to the refence time instead of
local time?

--
Miroslav Lichvar

--
To unsubscribe email chrony-users-request@xxxxxxxxxxxxxxxxxxxx
with "unsubscribe" in the subject.
For help email chrony-users-request@xxxxxxxxxxxxxxxxxxxx
with "help" in the subject.
Trouble?  Email listmaster@xxxxxxxxxxxxxxxxxxxx.




Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/