client: print positive signed freq and offset values with sign

This commit is contained in:
Miroslav Lichvar 2014-03-20 15:51:51 +01:00
parent ce34aa0763
commit 7dd3cc354d
2 changed files with 17 additions and 5 deletions

View file

@ -1669,6 +1669,18 @@ print_freq_ppm(double f)
/* ================================================== */
static void
print_signed_freq_ppm(double f)
{
if (fabs(f) < 99999.5) {
printf("%+10.3f", f);
} else {
printf("%+10.0f", f);
}
}
/* ================================================== */
static int
check_for_verbose_flag(char *line)
{
@ -1863,7 +1875,7 @@ process_cmd_sourcestats(char *line)
printf("%-25s %3lu %3lu ", hostname_buf, n_samples, n_runs);
print_seconds(span_seconds);
printf(" ");
print_freq_ppm(resid_freq_ppm);
print_signed_freq_ppm(resid_freq_ppm);
printf(" ");
print_freq_ppm(skew_ppm);
printf(" ");
@ -1952,7 +1964,7 @@ process_cmd_tracking(char *line)
rms_offset = UTI_FloatNetworkToHost(reply.data.tracking.rms_offset);
printf("System time : %.9f seconds %s of NTP time\n", fabs(correction),
(correction > 0.0) ? "slow" : "fast");
printf("Last offset : %.9f seconds\n", last_offset);
printf("Last offset : %+.9f seconds\n", last_offset);
printf("RMS offset : %.9f seconds\n", rms_offset);
freq_ppm = UTI_FloatNetworkToHost(reply.data.tracking.freq_ppm);
resid_freq_ppm = UTI_FloatNetworkToHost(reply.data.tracking.resid_freq_ppm);
@ -1961,7 +1973,7 @@ process_cmd_tracking(char *line)
root_dispersion = UTI_FloatNetworkToHost(reply.data.tracking.root_dispersion);
last_update_interval = UTI_FloatNetworkToHost(reply.data.tracking.last_update_interval);
printf("Frequency : %.3f ppm %s\n", fabs(freq_ppm), (freq_ppm < 0.0) ? "slow" : "fast");
printf("Residual freq : %.3f ppm\n", resid_freq_ppm);
printf("Residual freq : %+.3f ppm\n", resid_freq_ppm);
printf("Skew : %.3f ppm\n", skew_ppm);
printf("Root delay : %.6f seconds\n", root_delay);
printf("Root dispersion : %.6f seconds\n", root_dispersion);

View file

@ -15,10 +15,10 @@ check_chronyc_output "^Reference ID : 192\.168\.123\.1 \(192\.168\.123\.1\)
Stratum : 2
Ref time \(UTC\) : Fri Jan 1 00:1.:.. 2010
System time : 0\.0000..... seconds (slow|fast) of NTP time
Last offset : -?0\.0000..... seconds
Last offset : [+-]0\.0000..... seconds
RMS offset : 0\.000...... seconds
Frequency : (99|100)\.... ppm fast
Residual freq : -?[0-9]\.... ppm
Residual freq : [+-][0-9]\.... ppm
Skew : [0-9]\.... ppm
Root delay : 0\.000... seconds
Root dispersion : 0\.000... seconds