MCPcopy Create free account
hub / github.com/facebook/time / SysoffFromPrecise

Function SysoffFromPrecise

phc/offset.go:64–74  ·  view source on GitHub ↗

SysoffFromPrecise returns SysoffResult from *PTPSysOffsetPrecise . Code based on sysoff_precise from ptp4l sysoff.c

(pre *PTPSysOffsetPrecise)

Source from the content-addressed store, hash-verified

62
63// SysoffFromPrecise returns SysoffResult from *PTPSysOffsetPrecise . Code based on sysoff_precise from ptp4l sysoff.c
64func SysoffFromPrecise(pre *PTPSysOffsetPrecise) SysoffResult {
65 tp := time.Unix(pre.Device.Sec, int64(pre.Device.Nsec))
66 tr := time.Unix(pre.Monoraw.Sec, int64(pre.Monoraw.Nsec))
67 return SysoffResult{
68 SysTime: tr,
69 SysClockID: unix.CLOCK_MONOTONIC_RAW,
70 PHCTime: tp,
71 Delay: 0, // They are measured at the same time
72 Offset: tr.Sub(tp),
73 }
74}
75
76// SysoffEstimateBasic logic based on calculate_offset from ptp4l phc_ctl.c
77func SysoffEstimateBasic(ts1, rt, ts2 time.Time) SysoffResult {

Callers 5

phcdiffRunFunction · 0.92
phc2phcRunFunction · 0.92
TestSysoffFromPreciseFunction · 0.85
TimeAndOffsetFromDeviceFunction · 0.85

Calls 2

UnixMethod · 0.80
SubMethod · 0.45

Tested by 1

TestSysoffFromPreciseFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…