BestSample finds a sample which took the least time to be read; the logic is loosely based on sysoff_estimate from ptp4l sysoff.c
()
| 90 | // BestSample finds a sample which took the least time to be read; |
| 91 | // the logic is loosely based on sysoff_estimate from ptp4l sysoff.c |
| 92 | func (extended *PTPSysOffsetExtended) BestSample() SysoffResult { |
| 93 | best := sysoffFromExtendedTS(extended.Ts[0]) |
| 94 | for i := 1; i < int(extended.Samples); i++ { |
| 95 | sysoff := sysoffFromExtendedTS(extended.Ts[i]) |
| 96 | if sysoff.Delay < best.Delay { |
| 97 | best = sysoff |
| 98 | } |
| 99 | } |
| 100 | best.SysClockID = int(extended.ClockID) |
| 101 | return best |
| 102 | } |
| 103 | |
| 104 | // TimeAndOffsetFromDevice returns time we got from phc device + offset |
| 105 | func TimeAndOffsetFromDevice(device string, method TimeMethod) (SysoffResult, error) { |