From 097b43382581327b9709891cfe8cf75cc04b2983 Mon Sep 17 00:00:00 2001 From: Tim Ryan Date: Thu, 16 Jul 2015 17:01:37 -0700 Subject: [PATCH 1/3] Enables moddebug for VERBOSE outputs. --- tests/sitl/__main__.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/sitl/__main__.py b/tests/sitl/__main__.py index c7e6b91ce..d2dc2285f 100755 --- a/tests/sitl/__main__.py +++ b/tests/sitl/__main__.py @@ -184,6 +184,7 @@ def lets_run_a_test(name): # NOTE these are *very inappropriate settings* # to make on a real vehicle. They are leveraged # exclusively for simulation. Take heed!!! + p.stdin.write('set moddebug 3\n') p.stdin.write('param set ARMING_CHECK 0\n') p.stdin.write('param set FS_THR_ENABLE 0\n') p.stdin.write('param set FS_GCS_ENABLE 0\n') From 0939dad2db95243a0c89ec64b3bf05032c3ddace Mon Sep 17 00:00:00 2001 From: Tim Ryan Date: Thu, 16 Jul 2015 17:01:58 -0700 Subject: [PATCH 2/3] Adds a test to ensure no regressions in #115. --- tests/sitl/test_115.py | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 tests/sitl/test_115.py diff --git a/tests/sitl/test_115.py b/tests/sitl/test_115.py new file mode 100644 index 000000000..4805e92d9 --- /dev/null +++ b/tests/sitl/test_115.py @@ -0,0 +1,37 @@ +from droneapi.lib import VehicleMode +from pymavlink import mavutil +import time +import sys +import os + +def test_115(local_connect): + api = local_connect() + v = api.get_vehicles()[0] + + # Dummy callback + def noop(*args): + pass + + # Set the callback. + v.set_mavlink_callback(noop) + + # Change the vehicle into STABILIZE mode + v.mode = VehicleMode("STABILIZE") + + # NOTE wait crudely for ACK on mode update + time.sleep(3) + + # Unset the callback. + v.set_mavlink_callback(None) + + # Disarm should not throw errors. + v.armed = False + v.flush() + + time.sleep(3) + + # Re-arm should not throw errors. + v.armed = True + v.flush() + + time.sleep(3) From 70637e58f92224c2ca5623a01f6d8583d40882b7 Mon Sep 17 00:00:00 2001 From: Tim Ryan Date: Thu, 16 Jul 2015 17:03:03 -0700 Subject: [PATCH 3/3] Enables set_mavlink_callback to be passed None. Fixes #115 --- droneapi/module/api.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/droneapi/module/api.py b/droneapi/module/api.py index 0992a1e7a..245d7b0c8 100644 --- a/droneapi/module/api.py +++ b/droneapi/module/api.py @@ -489,7 +489,7 @@ def set(chnum, v): self.__on_change('rangefinder') - if (self.vehicle is not None) and hasattr(self.vehicle, 'mavrx_callback'): + if (self.vehicle is not None) and getattr(self.vehicle, 'mavrx_callback', None): self.vehicle.mavrx_callback(m) self.send_to_server(m)