clocksync: Fix serialqueue.set_clock_est() - don't track min_freq
Revert commit f37fc775
. It is not valid to pass a conservative
frequency to serialqueue.set_clock_est() as that function may not be
called for extended periods - a too low frequency would eventually
lead to "Timer too close" mcu errors.
Instead, increase the 1ms time offset to 5ms to avoid corner cases
that could lead to a message arriving too soon.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
parent
1518032606
commit
ba837c2641
|
@ -7,6 +7,7 @@ import logging, threading
|
|||
|
||||
COMM_TIMEOUT = 3.5
|
||||
RTT_AGE = .000010 / (60. * 60.)
|
||||
TRANSMIT_EXTRA = .005
|
||||
|
||||
class ClockSync:
|
||||
def __init__(self, reactor):
|
||||
|
@ -19,7 +20,6 @@ class ClockSync:
|
|||
self.min_half_rtt = 999999999.9
|
||||
self.min_half_rtt_time = 0.
|
||||
self.clock_est = self.prev_est = (0., 0, 0.)
|
||||
self.min_freq = 0.
|
||||
self.last_clock_fast = False
|
||||
def connect(self, serial):
|
||||
self.serial = serial
|
||||
|
@ -31,7 +31,6 @@ class ClockSync:
|
|||
self.last_clock = clock = (params['high'] << 32) | params['clock']
|
||||
new_time = .5 * (params['#sent_time'] + params['#receive_time'])
|
||||
self.clock_est = self.prev_est = (new_time, clock, self.mcu_freq)
|
||||
self.min_freq = self.mcu_freq
|
||||
# Enable periodic get_status timer
|
||||
self.status_cmd = msgparser.create_command('get_status')
|
||||
for i in range(8):
|
||||
|
@ -86,10 +85,9 @@ class ClockSync:
|
|||
if clock_fast != self.last_clock_fast:
|
||||
self.prev_est = self.clock_est
|
||||
self.last_clock_fast = clock_fast
|
||||
new_freq = (self.prev_est[1] - clock) / (self.prev_est[0] - new_time)
|
||||
self.min_freq = min(self.min_freq, new_freq)
|
||||
new_freq = (clock - self.prev_est[1]) / (new_time - self.prev_est[0])
|
||||
self.serial.set_clock_est(
|
||||
self.min_freq, new_time + self.min_half_rtt + 0.001, clock)
|
||||
new_freq, new_time + self.min_half_rtt + TRANSMIT_EXTRA, clock)
|
||||
self.clock_est = (new_time, clock, new_freq)
|
||||
# clock frequency conversions
|
||||
def print_time_to_clock(self, print_time):
|
||||
|
|
Loading…
Reference in New Issue