From 94dd186cdf4f16e54254c823e8b7aa7b49451555 Mon Sep 17 00:00:00 2001 From: Richard Cochran Date: Fri, 31 Aug 2012 16:04:12 +0200 Subject: [PATCH] Add a clock method to receive the follow up information TLV. Signed-off-by: Richard Cochran --- clock.c | 10 ++++++++++ clock.h | 8 ++++++++ tlv.h | 7 +++++++ 3 files changed, 25 insertions(+) diff --git a/clock.c b/clock.c index b0e65a5..1cf6740 100644 --- a/clock.c +++ b/clock.c @@ -70,6 +70,7 @@ struct clock { tmv_t path_delay; struct mave *avg_delay; struct freq_estimator fest; + struct time_status_np status; double nrr; tmv_t c1; tmv_t c2; @@ -473,6 +474,15 @@ UInteger8 clock_domain_number(struct clock *c) return c->dds.domainNumber; } +void clock_follow_up_info(struct clock *c, struct follow_up_info_tlv *f) +{ + c->status.cumulativeScaledRateOffset = f->cumulativeScaledRateOffset; + c->status.scaledLastGmPhaseChange = f->scaledLastGmPhaseChange; + c->status.gmTimeBaseIndicator = f->gmTimeBaseIndicator; + memcpy(&c->status.lastGmPhaseChange, &f->lastGmPhaseChange, + sizeof(c->status.lastGmPhaseChange)); +} + struct ClockIdentity clock_identity(struct clock *c) { return c->dds.clockIdentity; diff --git a/clock.h b/clock.h index c801da7..7e60334 100644 --- a/clock.h +++ b/clock.h @@ -24,6 +24,7 @@ #include "ds.h" #include "config.h" #include "servo.h" +#include "tlv.h" #include "tmv.h" #include "transport.h" @@ -90,6 +91,13 @@ void clock_destroy(struct clock *c); */ UInteger8 clock_domain_number(struct clock *c); +/** + * Provide the follow_up info TLV from a slave port. + * @param c The clock instance. + * @param f Pointer to the TLV. + */ +void clock_follow_up_info(struct clock *c, struct follow_up_info_tlv *f); + /** * Obtain a clock's identity from its default data set. * @param c The clock instance. diff --git a/tlv.h b/tlv.h index e9cb25d..0e61230 100644 --- a/tlv.h +++ b/tlv.h @@ -165,6 +165,13 @@ struct follow_up_info_tlv { Integer32 scaledLastGmPhaseChange; } PACKED; +struct time_status_np { + UInteger32 cumulativeScaledRateOffset; + Integer32 scaledLastGmPhaseChange; + UInteger16 gmTimeBaseIndicator; + ScaledNs lastGmPhaseChange; +} PACKED; + /** * Converts recognized value sub-fields into host byte order. * @param tlv Pointer to a Type Length Value field.