Skip to content

Commit

Permalink
Merge pull request #611 from fnoop/master
Browse files Browse the repository at this point in the history
#610: Wrap iterable call in try..except to deal with unrecognised vehicle codes
  • Loading branch information
mrpollo committed Apr 19, 2016
2 parents b91bf76 + 7ae2c51 commit 9b27f34
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
5 changes: 4 additions & 1 deletion dronekit/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1521,7 +1521,10 @@ def _mode_mapping_bynumber(self):
return mavutil.mode_mapping_bynumber(self._vehicle_type)

def _is_mode_available(self, mode_code):
return mode_code in self._mode_mapping_bynumber
try:
return mode_code in self._mode_mapping_bynumber
except:
return False

#
# Operations to support the standard API.
Expand Down
23 changes: 23 additions & 0 deletions dronekit/test/sitl/test_modeavailable.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
"""
Simple test to trigger a bug in Vehicle class: issue #610 fixed in PR #611
"""

import time
import sys
import os
from dronekit import connect, VehicleMode
from dronekit.test import with_sitl
from nose.tools import assert_equals

@with_sitl
def test_timeout(connpath):
v = connect(connpath)

# Set the vehicle and autopilot type to 'unsupported' types that MissionPlanner uses as of 17.Apr.2016
v._vehicle_type = 6
v._autopilot_type = 8

# The above types trigger 'TypeError: argument of type 'NoneType' is not iterable' which is addressed in issue #610
is_available = v._is_mode_available(0)

v.close()

0 comments on commit 9b27f34

Please sign in to comment.