Tools: autotest: factor out starting of our our mavlink connection

This commit is contained in:
Peter Barker 2018-08-04 09:20:15 +10:00 committed by Peter Barker
parent 9aca96b7da
commit af37e10126
6 changed files with 23 additions and 55 deletions

View File

@ -89,17 +89,8 @@ class AutoTestRover(AutoTest):
self.progress("Started simulator")
# get a mavlink connection going
connection_string = '127.0.0.1:19550'
try:
self.mav = mavutil.mavlink_connection(connection_string,
robust_parsing=True)
except Exception as msg:
self.progress("Failed to start mavlink connection on %s" %
connection_string)
raise
self.mav.message_hooks.append(self.message_hook)
self.mav.idle_hooks.append(self.idle_hook)
self.get_mavlink_connection_going()
self.hasInit = True
self.apply_defaultfile_parameters()

View File

@ -114,17 +114,8 @@ class AutoTestCopter(AutoTest):
self.progress("Started simulator")
# get a mavlink connection going
connection_string = '127.0.0.1:19550'
try:
self.mav = mavutil.mavlink_connection(connection_string,
robust_parsing=True)
except Exception as msg:
self.progress("Failed to start mavlink connection on %s: %s" %
(connection_string, msg,))
raise
self.mav.message_hooks.append(self.message_hook)
self.mav.idle_hooks.append(self.idle_hook)
self.get_mavlink_connection_going()
self.hasInit = True
self.progress("Ready to start testing!")

View File

@ -83,17 +83,8 @@ class AutoTestPlane(AutoTest):
self.progress("Started simulator")
# get a mavlink connection going
connection_string = '127.0.0.1:19550'
try:
self.mav = mavutil.mavlink_connection(connection_string,
robust_parsing=True)
except Exception as msg:
self.progress("Failed to start mavlink connection on %s: %s"
% (connection_string, msg))
raise
self.mav.message_hooks.append(self.message_hook)
self.mav.idle_hooks.append(self.idle_hook)
self.get_mavlink_connection_going()
self.hasInit = True
self.progress("Ready to start testing!")

View File

@ -78,17 +78,8 @@ class AutoTestSub(AutoTest):
self.progress("Started simulator")
# get a mavlink connection going
connection_string = '127.0.0.1:19550'
try:
self.mav = mavutil.mavlink_connection(connection_string,
robust_parsing=True)
except Exception as msg:
self.progress("Failed to start mavlink connection on %s: %s" %
(connection_string, msg,))
raise
self.mav.message_hooks.append(self.message_hook)
self.mav.idle_hooks.append(self.idle_hook)
self.get_mavlink_connection_going()
self.hasInit = True
self.apply_defaultfile_parameters()

View File

@ -861,6 +861,19 @@ class AutoTest(ABC):
self.progress("Failed to get EKF.flags=%u" % required_value)
raise AutoTestTimeoutException()
def get_mavlink_connection_going(self):
# get a mavlink connection going
connection_string = '127.0.0.1:19550'
try:
self.mav = mavutil.mavlink_connection(connection_string,
robust_parsing=True)
except Exception as msg:
self.progress("Failed to start mavlink connection on %s: %s" %
(connection_string, msg,))
raise
self.mav.message_hooks.append(self.message_hook)
self.mav.idle_hooks.append(self.idle_hook)
def run_test(self, desc, function, interact=False):
self.progress("#")
self.progress("########## %s ##########" % (desc))

View File

@ -82,17 +82,8 @@ class AutoTestQuadPlane(AutoTest):
self.progress("Started simulator")
# get a mavlink connection going
connection_string = '127.0.0.1:19550'
try:
self.mav = mavutil.mavlink_connection(connection_string,
robust_parsing=True)
except Exception as msg:
self.progress("Failed to start mavlink connection on %s: %s" %
(connection_string, msg))
raise
self.mav.message_hooks.append(self.message_hook)
self.mav.idle_hooks.append(self.idle_hook)
self.get_mavlink_connection_going()
self.hasInit = True
self.progress("Ready to start testing!")