SysoffFromPrecise returns SysoffResult from *PTPSysOffsetPrecise . Code based on sysoff_precise from ptp4l sysoff.c
(pre *PTPSysOffsetPrecise)
| 62 | |
| 63 | // SysoffFromPrecise returns SysoffResult from *PTPSysOffsetPrecise . Code based on sysoff_precise from ptp4l sysoff.c |
| 64 | func 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 |
| 77 | func SysoffEstimateBasic(ts1, rt, ts2 time.Time) SysoffResult { |
searching dependent graphs…