Thank you for your response! I'm now even more curious as to what the offset value printed by the LinuxPTP tools actually mean.
I assumed that since those tools are capable of printing the offset, they contain code which does just that. In my naïve view, I thought that once the slave had been synchronized, the slave's clock frequency/phase had been adjusted to be somewhat 'locked' to the freq/phase of the master's clock. Isn't that the whole purpose behind PTP? Keeping track on the difference between master and slave values of seconds and nanoseconds and adjusting the slave's clock frequency so that slave calls to eg. clock_realtime result in values with high accuracy (i.e that the error between slave time and master time is kept low). /Alex Den tors 29 apr. 2021 00:39Jacob Keller <jacob.e.kel...@intel.com> skrev: > > > On 4/28/2021 10:14 AM, Chris Rajula wrote: > > Thank you! > > > > It seems like setting the 'step_threshold' solved the stepping issue for > me. > > > > Now, for a follow-up question: > > I've looked but have not yet found any guide(s) on how to perform the > > following from within a C program: > > > > * Retrieve the master's time > > * Retrieve the offset between the slave's time and the master's time > > > > So, retrieving offset between the two clocks is pretty complex (hence > the entire reason PTP exists.. synchronizing clocks is hard!) > > You can't just "clock_gettime" on each clock and compare. How do you > know those times were captured at the same time? > > You might be able to use more advanced comparison methods such as PCIe > PTM (if the clock hardware on the PCIe device supports it, and if you're > comparing to the ART derived TSC clock...) > > For local clocks you could also use the clock comparison functions that > have the kernel take clock_gettime inside the kernel and use an average. > But that is just an average, not very precise. > > > I assume that it should be as simple as executing two calls to > > 'clock_gettime', but that implies that I'll have to pass the correct > > 'clockid_t' values to 'clock_gettime. > > Getting the system's main clock should be simple by just passing > > CLOCK_REALTIME, but how can I determine which value of 'clockid_t' > > corresponds to the slave's PTP-synchronized clock? > > > > You can use ethtool -T to get the PTP clock device, however.... See above. > > > I've sifted through 'include/uapi/linux/time.h' but I can't seem to find > > any PTP-related clock definitions there. > > Or is my only recourse to go through the LinuxPTP userspace code? > > > > Thanks, > > /Alex > > I would recommend looking at how the ioctls for PTP. I don't think there > are generic offset comparison functions for clocks in general. > > Thanks, > Jake > > > _______________________________________________ > Linuxptp-users mailing list > Linuxptp-users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/linuxptp-users >
_______________________________________________ Linuxptp-users mailing list Linuxptp-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linuxptp-users