based on sysoff_estimate from ptp4l sysoff.c
(extendedTS [3]PtpClockTime)
| 46 | |
| 47 | // based on sysoff_estimate from ptp4l sysoff.c |
| 48 | func sysoffFromExtendedTS(extendedTS [3]PtpClockTime) SysoffResult { |
| 49 | t1 := time.Unix(extendedTS[0].Sec, int64(extendedTS[0].Nsec)) |
| 50 | tp := time.Unix(extendedTS[1].Sec, int64(extendedTS[1].Nsec)) |
| 51 | t2 := time.Unix(extendedTS[2].Sec, int64(extendedTS[2].Nsec)) |
| 52 | interval := t2.Sub(t1) |
| 53 | timestamp := t1.Add(interval / 2) |
| 54 | offset := timestamp.Sub(tp) |
| 55 | return SysoffResult{ |
| 56 | SysTime: timestamp, |
| 57 | PHCTime: tp, |
| 58 | Delay: interval, |
| 59 | Offset: offset, |
| 60 | } |
| 61 | } |
| 62 | |
| 63 | // SysoffFromPrecise returns SysoffResult from *PTPSysOffsetPrecise . Code based on sysoff_precise from ptp4l sysoff.c |
| 64 | func SysoffFromPrecise(pre *PTPSysOffsetPrecise) SysoffResult { |
searching dependent graphs…