mirror of https://github.com/ArduPilot/ardupilot
autotest: use idle_hooks to prevent lockup
This commit is contained in:
parent
df957db8d9
commit
f30bca01c9
|
@ -286,6 +286,7 @@ def fly_ArduCopter(viewerip=None):
|
|||
print("Failed to start mavlink connection on 127.0.0.1:19550" % msg)
|
||||
raise
|
||||
mav.message_hooks.append(message_hook)
|
||||
mav.idle_hooks.append(idle_hook)
|
||||
|
||||
|
||||
failed = False
|
||||
|
|
|
@ -4,17 +4,21 @@ import util, pexpect, time, math
|
|||
# messages. This keeps the output to stdout flowing
|
||||
expect_list = []
|
||||
|
||||
def message_hook(mav, msg):
|
||||
'''called as each mavlink msg is received'''
|
||||
def idle_hook(mav):
|
||||
'''called when waiting for a mavlink message'''
|
||||
global expect_list
|
||||
# if msg.get_type() in [ 'NAV_CONTROLLER_OUTPUT', 'GPS_RAW' ]:
|
||||
# print(msg)
|
||||
for p in expect_list:
|
||||
try:
|
||||
p.read_nonblocking(100, timeout=0)
|
||||
except pexpect.TIMEOUT:
|
||||
pass
|
||||
|
||||
def message_hook(mav, msg):
|
||||
'''called as each mavlink msg is received'''
|
||||
# if msg.get_type() in [ 'NAV_CONTROLLER_OUTPUT', 'GPS_RAW' ]:
|
||||
# print(msg)
|
||||
idle_hook(mav)
|
||||
|
||||
def expect_callback(e):
|
||||
'''called when waiting for a expect pattern'''
|
||||
global expect_list
|
||||
|
|
Loading…
Reference in New Issue