Write banner to tracking log when not synchronized
This commit is contained in:
parent
4a9205b341
commit
902ed3c694
1 changed files with 25 additions and 36 deletions
61
reference.c
61
reference.c
|
@ -87,9 +87,6 @@ static unsigned long logwrites = 0;
|
||||||
|
|
||||||
/* ================================================== */
|
/* ================================================== */
|
||||||
|
|
||||||
/* Day number of 1 Jan 1970 */
|
|
||||||
#define MJD_1970 40587
|
|
||||||
|
|
||||||
/* Reference ID supplied when we are locally referenced */
|
/* Reference ID supplied when we are locally referenced */
|
||||||
#define LOCAL_REFERENCE_ID 0x7f7f0101UL
|
#define LOCAL_REFERENCE_ID 0x7f7f0101UL
|
||||||
|
|
||||||
|
@ -359,6 +356,26 @@ update_leap_status(NTP_Leap leap)
|
||||||
|
|
||||||
/* ================================================== */
|
/* ================================================== */
|
||||||
|
|
||||||
|
static void
|
||||||
|
write_log(struct timeval *ref_time, char *ref, int stratum, double freq, double skew, double offset)
|
||||||
|
{
|
||||||
|
if (logfile) {
|
||||||
|
|
||||||
|
if (((logwrites++) % 32) == 0) {
|
||||||
|
fprintf(logfile,
|
||||||
|
"=======================================================================\n"
|
||||||
|
" Date (UTC) Time IP Address St Freq ppm Skew ppm Offset\n"
|
||||||
|
"=======================================================================\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
fprintf(logfile, "%s %-15s %2d %10.3f %10.3f %10.3e\n",
|
||||||
|
UTI_TimeToLogForm(ref_time->tv_sec), ref, stratum, freq, skew, offset);
|
||||||
|
|
||||||
|
fflush(logfile);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ================================================== */
|
||||||
|
|
||||||
void
|
void
|
||||||
REF_SetReference(int stratum,
|
REF_SetReference(int stratum,
|
||||||
|
@ -472,26 +489,13 @@ REF_SetReference(int stratum,
|
||||||
|
|
||||||
abs_freq_ppm = LCL_ReadAbsoluteFrequency();
|
abs_freq_ppm = LCL_ReadAbsoluteFrequency();
|
||||||
|
|
||||||
if (logfile) {
|
write_log(ref_time,
|
||||||
|
|
||||||
if (((logwrites++) % 32) == 0) {
|
|
||||||
fprintf(logfile,
|
|
||||||
"=======================================================================\n"
|
|
||||||
" Date (UTC) Time IP Address St Freq ppm Skew ppm Offset\n"
|
|
||||||
"=======================================================================\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
fprintf(logfile, "%s %-15s %2d %10.3f %10.3f %10.3e\n",
|
|
||||||
UTI_TimeToLogForm(ref_time->tv_sec),
|
|
||||||
our_ref_ip.family != IPADDR_UNSPEC ? UTI_IPToString(&our_ref_ip) : UTI_RefidToString(our_ref_id),
|
our_ref_ip.family != IPADDR_UNSPEC ? UTI_IPToString(&our_ref_ip) : UTI_RefidToString(our_ref_id),
|
||||||
our_stratum,
|
our_stratum,
|
||||||
abs_freq_ppm,
|
abs_freq_ppm,
|
||||||
1.0e6*our_skew,
|
1.0e6*our_skew,
|
||||||
our_offset);
|
our_offset);
|
||||||
|
|
||||||
fflush(logfile);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (drift_file) {
|
if (drift_file) {
|
||||||
update_drift_file(abs_freq_ppm, our_skew);
|
update_drift_file(abs_freq_ppm, our_skew);
|
||||||
}
|
}
|
||||||
|
@ -514,7 +518,6 @@ REF_SetManualReference
|
||||||
double skew
|
double skew
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
int millisecond;
|
|
||||||
double abs_freq_ppm;
|
double abs_freq_ppm;
|
||||||
|
|
||||||
/* We are not synchronised to an external source, as such. This is
|
/* We are not synchronised to an external source, as such. This is
|
||||||
|
@ -530,20 +533,13 @@ REF_SetManualReference
|
||||||
|
|
||||||
abs_freq_ppm = LCL_ReadAbsoluteFrequency();
|
abs_freq_ppm = LCL_ReadAbsoluteFrequency();
|
||||||
|
|
||||||
if (logfile) {
|
write_log(ref_time,
|
||||||
millisecond = ref_time->tv_usec / 1000;
|
|
||||||
|
|
||||||
fprintf(logfile, "%5s %-15s %2d %10.3f %10.3f %10.3e\n",
|
|
||||||
UTI_TimeToLogForm(ref_time->tv_sec),
|
|
||||||
"127.127.1.1",
|
"127.127.1.1",
|
||||||
our_stratum,
|
our_stratum,
|
||||||
abs_freq_ppm,
|
abs_freq_ppm,
|
||||||
1.0e6*our_skew,
|
1.0e6*our_skew,
|
||||||
our_offset);
|
our_offset);
|
||||||
|
|
||||||
fflush(logfile);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (drift_file) {
|
if (drift_file) {
|
||||||
update_drift_file(abs_freq_ppm, our_skew);
|
update_drift_file(abs_freq_ppm, our_skew);
|
||||||
}
|
}
|
||||||
|
@ -555,27 +551,20 @@ void
|
||||||
REF_SetUnsynchronised(void)
|
REF_SetUnsynchronised(void)
|
||||||
{
|
{
|
||||||
/* Variables required for logging to statistics log */
|
/* Variables required for logging to statistics log */
|
||||||
int millisecond;
|
|
||||||
struct timeval now;
|
struct timeval now;
|
||||||
double local_clock_err;
|
double local_clock_err;
|
||||||
|
|
||||||
assert(initialised);
|
assert(initialised);
|
||||||
|
|
||||||
if (logfile) {
|
LCL_ReadCookedTime(&now, &local_clock_err);
|
||||||
LCL_ReadCookedTime(&now, &local_clock_err);
|
|
||||||
|
|
||||||
millisecond = now.tv_usec / 1000;
|
write_log(&now,
|
||||||
|
|
||||||
fprintf(logfile, "%s %-15s 0 %10.3f %10.3f %10.3e\n",
|
|
||||||
UTI_TimeToLogForm(now.tv_sec),
|
|
||||||
"0.0.0.0",
|
"0.0.0.0",
|
||||||
|
0,
|
||||||
LCL_ReadAbsoluteFrequency(),
|
LCL_ReadAbsoluteFrequency(),
|
||||||
1.0e6*our_skew,
|
1.0e6*our_skew,
|
||||||
0.0);
|
0.0);
|
||||||
|
|
||||||
fflush(logfile);
|
|
||||||
}
|
|
||||||
|
|
||||||
are_we_synchronised = 0;
|
are_we_synchronised = 0;
|
||||||
|
|
||||||
update_leap_status(LEAP_Unsynchronised);
|
update_leap_status(LEAP_Unsynchronised);
|
||||||
|
|
Loading…
Reference in a new issue