Browse Source

autotest: read pexpects while waiting for sim time

If we do not drain pexpects regularly the ardupilot process can become blocked on terminal IO
gps-1.3.1
Peter Barker 3 years ago committed by Peter Barker
parent
commit
2dd392ec4b
  1. 15
      Tools/autotest/common.py

15
Tools/autotest/common.py

@ -2761,10 +2761,17 @@ class AutoTest(ABC): @@ -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."""

Loading…
Cancel
Save