Tools: autotest: make reboot detection more reliable

This commit is contained in:
Peter Barker 2018-12-13 15:45:43 +11:00 committed by Peter Barker
parent fbf072d84b
commit ec288cd867
3 changed files with 30 additions and 10 deletions

View File

@ -107,6 +107,8 @@ class AutoTestCopter(AutoTest):
self.progress("WAITING FOR PARAMETERS")
self.mavproxy.expect('Received [0-9]+ parameters')
self.get_mavlink_connection_going()
self.apply_defaultfile_parameters()
util.expect_setup_callback(self.mavproxy, self.expect_callback)
@ -116,8 +118,6 @@ class AutoTestCopter(AutoTest):
self.progress("Started simulator")
self.get_mavlink_connection_going()
self.hasInit = True
self.progress("Ready to start testing!")

View File

@ -153,6 +153,15 @@ class AutoTestSub(AutoTest):
if ex is not None:
raise ex
def reboot_sitl(self):
"""Reboot SITL instance and wait it to reconnect."""
self.mavproxy.send("reboot\n")
self.mavproxy.expect("Initialising APM")
# empty mav to avoid getting old timestamps:
while self.mav.recv_match(blocking=False):
pass
self.initialise_after_reboot_sitl()
def autotest(self):
"""Autotest ArduSub in SITL."""
self.check_test_syntax(test_file=os.path.realpath(__file__))

View File

@ -198,22 +198,33 @@ class AutoTest(ABC):
def reboot_sitl(self):
"""Reboot SITL instance and wait it to reconnect."""
old_bootcount= self.get_parameter('STAT_BOOTCNT')
self.mavproxy.send("reboot\n")
self.mavproxy.expect("Initialising APM")
# empty mav to avoid getting old timestamps:
if self.mav is not None:
while self.mav.recv_match(blocking=False):
tstart = self.get_sim_time()
while True:
if self.get_sim_time() - tstart > 10:
raise AutoTestTimeoutException("Did not detect reboot")
try:
if self.get_parameter('STAT_BOOTCNT', timeout=1) != old_bootcount:
break
except NotAchievedException:
pass
# empty mav to avoid getting old timestamps:
while self.mav.recv_match(blocking=False):
pass
self.initialise_after_reboot_sitl()
def initialise_after_reboot_sitl(self):
# after reboot stream-rates may be zero. Prompt MAVProxy to
# send a rate-change message by changing away from our normal
# stream rates and back again:
if self.mav is not None:
tstart = self.get_sim_time()
tstart = self.get_sim_time()
while True:
self.mavproxy.send("set streamrate %u\n" % (self.sitl_streamrate()+1))
if self.mav is None:
break
if self.get_sim_time() - tstart > 10:
raise AutoTestTimeoutException("SYSTEM_TIME not received")