Fix problems with rtc_linux.
2) Changes to rtc_linux.c which a) do a double read of /dev/rtc when the PPM interupt is turned on after the wait time expires. The current read does not block to the second, as it should, thus two reads are needed. Also, changes so that at startup the system properly ignores the last system time from the initial burst mode for setting the system time since it can be way off. At present this last system time is included in the regression, which throws it off until finally that sample is dropped.
This commit is contained in:
parent
3a8f93792b
commit
ce4e0a3c2f
1 changed files with 14 additions and 5 deletions
19
rtc_linux.c
19
rtc_linux.c
|
@ -174,7 +174,7 @@ static double file_ref_offset, file_rate_ppm;
|
||||||
/* ================================================== */
|
/* ================================================== */
|
||||||
|
|
||||||
/* Flag to remember whether to assume the RTC is running on UTC */
|
/* Flag to remember whether to assume the RTC is running on UTC */
|
||||||
static int rtc_on_utc = 0;
|
static int rtc_on_utc = 1;
|
||||||
|
|
||||||
/* ================================================== */
|
/* ================================================== */
|
||||||
|
|
||||||
|
@ -226,15 +226,18 @@ accumulate_sample(time_t rtc, struct timeval *sys)
|
||||||
discard_samples(NEW_FIRST_WHEN_FULL);
|
discard_samples(NEW_FIRST_WHEN_FULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
rtc_sec[n_samples] = rtc;
|
|
||||||
|
|
||||||
/* Always use most recent sample as reference */
|
/* Always use most recent sample as reference */
|
||||||
|
/* use sample only if n_sample is not negative*/
|
||||||
|
if(n_samples >=0)
|
||||||
|
{
|
||||||
rtc_ref = rtc;
|
rtc_ref = rtc;
|
||||||
|
rtc_sec[n_samples] = rtc;
|
||||||
rtc_trim[n_samples] = 0.0;
|
rtc_trim[n_samples] = 0.0;
|
||||||
system_times[n_samples] = *sys;
|
system_times[n_samples] = *sys;
|
||||||
++n_samples;
|
|
||||||
++n_samples_since_regression;
|
++n_samples_since_regression;
|
||||||
|
}
|
||||||
|
++n_samples;
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -742,8 +745,12 @@ handle_initial_trim(void)
|
||||||
run_regression(1, &coefs_valid, &coef_ref_time, &coef_seconds_fast, &coef_gain_rate);
|
run_regression(1, &coefs_valid, &coef_ref_time, &coef_seconds_fast, &coef_gain_rate);
|
||||||
|
|
||||||
n_samples_since_regression = 0;
|
n_samples_since_regression = 0;
|
||||||
n_samples = 0;
|
|
||||||
|
|
||||||
|
/* Set sample number to -1 so the next sample is not used, as it will not yet be corrected for System Trim*/
|
||||||
|
|
||||||
|
n_samples = -1;
|
||||||
|
|
||||||
|
|
||||||
read_coefs_from_file();
|
read_coefs_from_file();
|
||||||
|
|
||||||
if (valid_coefs_from_file) {
|
if (valid_coefs_from_file) {
|
||||||
|
@ -866,6 +873,8 @@ read_from_device(void *any)
|
||||||
int error = 0;
|
int error = 0;
|
||||||
|
|
||||||
status = read(fd, &data, sizeof(data));
|
status = read(fd, &data, sizeof(data));
|
||||||
|
if (operating_mode == OM_NORMAL)
|
||||||
|
status = read(fd, &data, sizeof(data));
|
||||||
if (status < 0) {
|
if (status < 0) {
|
||||||
/* This looks like a bad error : the file descriptor was indicating it was
|
/* This looks like a bad error : the file descriptor was indicating it was
|
||||||
* ready to read but we couldn't read anything. Give up. */
|
* ready to read but we couldn't read anything. Give up. */
|
||||||
|
|
Loading…
Reference in a new issue