mirror of https://github.com/ArduPilot/ardupilot
Tools: autotest: factor out starting of our our mavlink connection
This commit is contained in:
parent
9aca96b7da
commit
af37e10126
|
@ -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()
|
||||
|
|
|
@ -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!")
|
||||
|
||||
|
|
|
@ -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!")
|
||||
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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))
|
||||
|
|
|
@ -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!")
|
||||
|
||||
|
|
Loading…
Reference in New Issue