From cb5ebd9b247021d6278ac36add7d40f1309e55c6 Mon Sep 17 00:00:00 2001 From: Miroslav Lichvar Date: Thu, 7 Feb 2013 19:56:51 +0100 Subject: [PATCH] Change label of frequency offset. Change the label of the frequency offset in the clock messages printed by ptp4l and phc2sys from "adj" to "freq" to indicate it's a frequency value. Also, modify clock_no_adjust() to print the frequency offset instead of the ratio and use PRId64 instead of lld to print int64_t values. Signed-off-by: Miroslav Lichvar --- clock.c | 11 +++++++---- phc2sys.c | 2 +- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/clock.c b/clock.c index d9d44df..281adff 100644 --- a/clock.c +++ b/clock.c @@ -235,7 +235,7 @@ static int clock_master_lost(struct clock *c) static enum servo_state clock_no_adjust(struct clock *c) { double fui; - double ratio; + double ratio, freq; tmv_t origin2; struct freq_estimator *f = &c->fest; enum servo_state state = SERVO_UNLOCKED; @@ -276,9 +276,11 @@ static enum servo_state clock_no_adjust(struct clock *c) ratio = tmv_dbl(tmv_sub(origin2, f->origin1)) / tmv_dbl(tmv_sub(c->t2, f->ingress1)); + freq = (1.0 - ratio) * 1e9; - pr_info("master offset %10lld s%d ratio %.9f path delay %10lld", - c->master_offset, state, ratio, c->path_delay); + pr_info("master offset %10" PRId64 " s%d freq %+7.0f " + "path delay %9" PRId64, + c->master_offset, state, freq, c->path_delay); fui = 1.0 + (c->status.cumulativeScaledRateOffset + 0.0) / POW2_41; @@ -901,7 +903,8 @@ enum servo_state clock_synchronize(struct clock *c, adj = servo_sample(c->servo, c->master_offset, ingress, &state); - pr_info("master offset %10lld s%d adj %+7.0f path delay %10lld", + pr_info("master offset %10" PRId64 " s%d freq %+7.0f " + "path delay %9" PRId64, c->master_offset, state, adj, c->path_delay); switch (state) { diff --git a/phc2sys.c b/phc2sys.c index 058feaa..b6be26d 100644 --- a/phc2sys.c +++ b/phc2sys.c @@ -174,7 +174,7 @@ static void update_clock(struct clock *clock, int64_t offset, uint64_t ts) break; } - pr_info("%s %9" PRId64 " s%d %lld.%09llu adj %.2f", + pr_info("%s %9" PRId64 " s%d %lld.%09llu freq %+7.0f", clock->source_label, offset, state, ts / NS_PER_SEC, ts % NS_PER_SEC, ppb); }