From 3ed1a527c8c2b3de616bccfed3e095f0058efc71 Mon Sep 17 00:00:00 2001 From: mszicsu Date: Mon, 27 Aug 2018 11:08:10 +0200 Subject: [PATCH] Fix statistics file output: - remove duplicated state if statistics_timestamp_format = both - zero out unused servo.driftMean and servo.driftStdDev --- src/dep/sys.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/dep/sys.c b/src/dep/sys.c index 3b0a28b9..1acf6d2d 100644 --- a/src/dep/sys.c +++ b/src/dep/sys.c @@ -624,19 +624,21 @@ logStatistics(PtpClock * ptpClock) if (global->statisticsTimestamp == TIMESTAMP_DATETIME || global->statisticsTimestamp == TIMESTAMP_BOTH) { strftime(time_str, MAXTIMESTR, "%Y-%m-%d %X", localtime(&time_s)); - len += snprintf(sbuf + len, sizeof(sbuf) - len, "%s.%06d, %s, ", - time_str, (int)now.nanoseconds/1000, /* Timestamp */ - translatePortState(ptpClock)); /* State */ + len += snprintf(sbuf + len, sizeof(sbuf) - len, "%s.%06d, ", + time_str, (int)now.nanoseconds/1000); /* Timestamp */ } /* output unix timestamp s.ns if configured */ if (global->statisticsTimestamp == TIMESTAMP_UNIX || global->statisticsTimestamp == TIMESTAMP_BOTH) { - len += snprintf(sbuf + len, sizeof(sbuf) - len, "%d.%06d, %s,", - now.seconds, now.nanoseconds, /* Timestamp */ - translatePortState(ptpClock)); /* State */ + len += snprintf(sbuf + len, sizeof(sbuf) - len, "%d.%06d, ", + now.seconds, now.nanoseconds); /* Timestamp */ } + /* output State */ + len += snprintf(sbuf + len, sizeof(sbuf) - len, "%s, ", + translatePortState(ptpClock)); /* State */ + if (ptpClock->portDS.portState == PTP_SLAVE) { len += snprint_PortIdentity(sbuf + len, sizeof(sbuf) - len, &ptpClock->parentDS.parentPortIdentity); /* Clock ID */ @@ -694,6 +696,8 @@ logStatistics(PtpClock * ptpClock) ptpClock->slaveStats.mpdStdDev * 1E9, ptpClock->slaveStats.ofmMean, ptpClock->slaveStats.ofmStdDev * 1E9); + + len += snprintf(sbuf + len, sizeof(sbuf) - len, ", 0, 0, "); /* zero out "Observed Drift Mean","Observed Drift Std Dev" */ /* len += snprintf(sbuf + len, sizeof(sbuf) - len, ", %.0f, %.0f, ", ptpClock->servo.driftMean,