diff --git a/clock.c b/clock.c index e3dadb5..709e21e 100644 --- a/clock.c +++ b/clock.c @@ -570,6 +570,8 @@ void clock_path_delay(struct clock *c, struct timespec req, struct timestamp rx, c->path_delay = mave_accumulate(c->avg_delay, pd); + c->cur.meanPathDelay = tmv_to_TimeInterval(c->path_delay); + pr_debug("path delay %10lld %10lld", c->path_delay, pd); } @@ -627,6 +629,8 @@ enum servo_state clock_synchronize(struct clock *c, c->master_offset = tmv_sub(ingress, tmv_add(origin, tmv_add(c->path_delay, tmv_add(c->c1, c->c2)))); + c->cur.offsetFromMaster = tmv_to_TimeInterval(c->master_offset); + if (!c->path_delay) return state; diff --git a/tmv.h b/tmv.h index e6689f0..bf48d09 100644 --- a/tmv.h +++ b/tmv.h @@ -71,6 +71,11 @@ static inline tmv_t correction_to_tmv(Integer64 c) return c >> 16; } +static inline TimeInterval tmv_to_TimeInterval(tmv_t x) +{ + return x << 16; +} + static inline tmv_t timespec_to_tmv(struct timespec ts) { return ts.tv_sec * NS_PER_SEC + ts.tv_nsec;