From 49fd762f2675c01a551d83e32d4be3bf4cbe16d4 Mon Sep 17 00:00:00 2001 From: Peter Barker Date: Wed, 14 Oct 2020 11:29:22 +1100 Subject: [PATCH] autotest: fix and re-enable button test A recent commit to fix the setting-of-pullup-resistors in SITL makes it possible to re-enable this. Closes #15259 --- Tools/autotest/arducopter.py | 1 - Tools/autotest/arduplane.py | 1 - Tools/autotest/common.py | 42 +++++++++++++++++------------------- Tools/autotest/rover.py | 1 - 4 files changed, 20 insertions(+), 25 deletions(-) diff --git a/Tools/autotest/arducopter.py b/Tools/autotest/arducopter.py index a5cb55db54..0b15fe65be 100644 --- a/Tools/autotest/arducopter.py +++ b/Tools/autotest/arducopter.py @@ -5599,7 +5599,6 @@ class AutoTestCopter(AutoTest): "Parachute": "See https://github.com/ArduPilot/ardupilot/issues/4702", "HorizontalAvoidFence": "See https://github.com/ArduPilot/ardupilot/issues/11525", "AltEstimation": "See https://github.com/ArduPilot/ardupilot/issues/15191", - "Button": "See https://github.com/ArduPilot/ardupilot/issues/15259", } class AutoTestHeli(AutoTestCopter): diff --git a/Tools/autotest/arduplane.py b/Tools/autotest/arduplane.py index e33209ea13..cfe9003022 100644 --- a/Tools/autotest/arduplane.py +++ b/Tools/autotest/arduplane.py @@ -2134,5 +2134,4 @@ class AutoTestPlane(AutoTest): def disabled_tests(self): return { - "Button": "See https://github.com/ArduPilot/ardupilot/issues/15259", } diff --git a/Tools/autotest/common.py b/Tools/autotest/common.py index b2acbfc8b6..2fd83eab3b 100644 --- a/Tools/autotest/common.py +++ b/Tools/autotest/common.py @@ -6746,9 +6746,16 @@ switch value''' self.set_parameter("BTN_PIN%u" % btn, pin) m = self.mav.recv_match(type='BUTTON_CHANGE', blocking=True, timeout=1) self.progress("### m: %s" % str(m)) - if m is None: - raise NotAchievedException("Did not get BUTTON_CHANGE event") + if m is not None: + # should not get a button-changed event here. The pins + # are simulated pull-down + raise NotAchievedException("Received BUTTON_CHANGE event") mask = 1< 10: - raise AutoTestTimeoutException("No BUTTON_CHANGE received") - m3 = self.mav.recv_match(type='BUTTON_CHANGE', blocking=True, timeout=1) - self.progress("### m3: %s" % str(m3)) - if m3 is None: - continue - if m.last_change_ms == m3.last_change_ms: - self.progress("last_change_ms same as first message") - continue - if m3.state != new_mask: - raise NotAchievedException("Unexpected mask (want=%u got=%u)" % - (new_mask, m3.state)) - self.progress("correct BUTTON_CHANGE event received") - break + m3 = self.mav.recv_match(type='BUTTON_CHANGE', blocking=True, timeout=1) + self.progress("### m3: %s" % str(m3)) + if m3 is None: + raise NotAchievedException("Did not get 'off' message") + + if m.last_change_ms == m3.last_change_ms: + raise NotAchievedException("last_change_ms same as first message") + if m3.state != new_mask: + raise NotAchievedException("Unexpected mask (want=%u got=%u)" % + (new_mask, m3.state)) + self.progress("correct BUTTON_CHANGE event received") def compare_number_percent(self, num1, num2, percent): if num1 == 0 and num2 == 0: diff --git a/Tools/autotest/rover.py b/Tools/autotest/rover.py index a352b2df18..2a53a0c408 100644 --- a/Tools/autotest/rover.py +++ b/Tools/autotest/rover.py @@ -5455,7 +5455,6 @@ Brakes have negligible effect (with=%0.2fm without=%0.2fm delta=%0.2fm) def disabled_tests(self): return { "DriveMaxRCIN": "currently triggers Arithmetic Exception", - "Button": "See https://github.com/ArduPilot/ardupilot/issues/15259", } def rc_defaults(self):