SysoffEstimateBasic logic based on calculate_offset from ptp4l phc_ctl.c
(ts1, rt, ts2 time.Time)
| 75 | |
| 76 | // SysoffFromPrecise returns SysoffResult from *PTPSysOffsetPrecise . Code based on sysoff_precise from ptp4l sysoff.c |
| 77 | func SysRToffFromPrecise(pre *PTPSysOffsetPrecise) SysoffResult { |
| 78 | tp := time.Unix(pre.Device.Sec, int64(pre.Device.Nsec)) |
| 79 | tr := time.Unix(pre.Realtime.Sec, int64(pre.Realtime.Nsec)) |
| 80 | return SysoffResult{ |
| 81 | SysTime: tr, |
| 82 | SysClockID: unix.CLOCK_REALTIME, |
| 83 | PHCTime: tp, |
| 84 | Delay: 0, // They are measured at the same time |
| 85 | Offset: tr.Sub(tp), |
| 86 | } |
| 87 | } |
| 88 | |
| 89 | // SysoffEstimateBasic logic based on calculate_offset from ptp4l phc_ctl.c |
| 90 | func SysoffEstimateBasic(ts1, rt, ts2 time.Time) SysoffResult { |
| 91 | interval := ts2.Sub(ts1) |
searching dependent graphs…