diff --git a/Tools/autotest/arducopter.py b/Tools/autotest/arducopter.py index 0b0bb93492..435e114fd0 100644 --- a/Tools/autotest/arducopter.py +++ b/Tools/autotest/arducopter.py @@ -1698,8 +1698,11 @@ class AutoTestCopter(AutoTest): if delta > max_delta: raise NotAchievedException("Did not land close enough to original position (%fm > %fm" % (delta, max_delta)) + if not self.current_onboard_log_contains_message("PL"): + raise NotAchievedException("Did not see expected PL message") + except Exception as e: - self.progress("Exception caught") + self.progress("Exception caught (%s)" % str(e)) ex = e self.zero_throttle() diff --git a/Tools/autotest/common.py b/Tools/autotest/common.py index 121bf4eae3..4af0de3909 100644 --- a/Tools/autotest/common.py +++ b/Tools/autotest/common.py @@ -13,7 +13,7 @@ import pexpect import fnmatch import operator -from pymavlink import mavwp, mavutil +from pymavlink import mavwp, mavutil, DFReader from pysim import util, vehicleinfo # a list of pexpect objects to read while waiting for @@ -2532,6 +2532,26 @@ switch value''' self.progress("##### %s is skipped: %s" % (name, reason)) self.skip_list.append((test, reason)) + def last_onboard_log(self): + '''return number of last onboard log''' + self.mavproxy.send("log list\n") + self.mavproxy.expect("lastLog ([0-9]+)") + return int(self.mavproxy.match.group(1)) + + def current_onboard_log_filepath(self): + '''return filepath to currently open dataflash log''' + return os.path.join("logs/%08u.BIN" % self.last_onboard_log()) + + def dfreader_for_current_onboard_log(self): + return DFReader.DFReader_binary(self.current_onboard_log_filepath(), + zero_time_base=True); + + def current_onboard_log_contains_message(self, messagetype): + dfreader = self.dfreader_for_current_onboard_log() + m = dfreader.recv_match(type=messagetype) + print("m=%s" % str(m)) + return m is not None + def run_tests(self, tests): """Autotest vehicle in SITL.""" if self.run_tests_called: