diff --git a/Tools/autotest/common.py b/Tools/autotest/common.py index 56930f9d38..7e33b2ad91 100644 --- a/Tools/autotest/common.py +++ b/Tools/autotest/common.py @@ -2761,10 +2761,17 @@ class AutoTest(ABC): def get_sim_time(self, timeout=60): """Get SITL time in seconds.""" self.drain_mav() - m = self.mav.recv_match(type='SYSTEM_TIME', blocking=True, timeout=timeout) - if m is None: - raise AutoTestTimeoutException("Did not get SYSTEM_TIME message after %f seconds" % timeout) - return m.time_boot_ms * 1.0e-3 + tstart = time.time() + while True: + self.drain_all_pexpects() + if time.time() - tstart > timeout: + raise AutoTestTimeoutException("Did not get SYSTEM_TIME message after %f seconds" % timeout) + + m = self.mav.recv_match(type='SYSTEM_TIME', blocking=True, timeout=0.1) + if m is None: + continue + + return m.time_boot_ms * 1.0e-3 def get_sim_time_cached(self): """Get SITL time in seconds."""