On Mon, Sep 11, 2023 at 16:46:07 +0200, Miroslav Lichvar wrote: > On Mon, Sep 11, 2023 at 08:03:49AM -0400, Josef 'Jeff' Sipek wrote: > > On Mon, Sep 11, 2023 at 10:29:30 +0200, Miroslav Lichvar wrote: > > > That timestamp doesn't need much resolution. It just says when the > > > offset (in double format) was captured. Milliseconds would be fine. > > > > Ok. I just saw that the code uses that the timestamp and the offset to > > calculate the time (for non-PPS sources) and it seemed desirable to get more > > than microsecond resolution for that before it gets fed into RCL_AddSample. > > In other words, this timestamp indirectly affects the resolution of the > > sample fed in. > > It's converted to timespec and then back to double after applying the > offset option. The resolution of the original timestamp doesn't > impact the resolution of the offset. It is effectively handled in > nanosecond resolution.
Just to make sure I understand, the "proper" way is to adjust the offset to compensate for any rounding? IOW, something like what I had in my program before I messed with chrony's code: uint64_t sys; /* system clock unix time in ns */ uint64_t ref; /* reference clock unix time in ns */ ... /* align sys time to microseconds, adjust ref time to maintain offset */ ref -= (sys % 1000); sys -= (sys % 1000); /* send message to chrony */ msg->tv.tv_sec = sys / 1000000000; msg->tv.tv_usec = (sys / 1000) % 1000000; msg->offset = (ref - sys) / 1e9; ... sendto(...) This assumes that time was linear during the sys%1000 nanoseconds. That seems reasonable but as I said, I want to make sure I understand the right way to feed chrony via the SOCK refclock. Thanks, Jeff. -- To unsubscribe email chrony-dev-requ...@chrony.tuxfamily.org with "unsubscribe" in the subject. For help email chrony-dev-requ...@chrony.tuxfamily.org with "help" in the subject. Trouble? Email listmas...@chrony.tuxfamily.org.