Skip to content

Commit 9b27f34

Browse files
committed
Merge pull request #611 from fnoop/master
#610: Wrap iterable call in try..except to deal with unrecognised vehicle codes
2 parents b91bf76 + 7ae2c51 commit 9b27f34

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

dronekit/__init__.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1521,7 +1521,10 @@ def _mode_mapping_bynumber(self):
15211521
return mavutil.mode_mapping_bynumber(self._vehicle_type)
15221522

15231523
def _is_mode_available(self, mode_code):
1524-
return mode_code in self._mode_mapping_bynumber
1524+
try:
1525+
return mode_code in self._mode_mapping_bynumber
1526+
except:
1527+
return False
15251528

15261529
#
15271530
# Operations to support the standard API.
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
"""
2+
Simple test to trigger a bug in Vehicle class: issue #610 fixed in PR #611
3+
"""
4+
5+
import time
6+
import sys
7+
import os
8+
from dronekit import connect, VehicleMode
9+
from dronekit.test import with_sitl
10+
from nose.tools import assert_equals
11+
12+
@with_sitl
13+
def test_timeout(connpath):
14+
v = connect(connpath)
15+
16+
# Set the vehicle and autopilot type to 'unsupported' types that MissionPlanner uses as of 17.Apr.2016
17+
v._vehicle_type = 6
18+
v._autopilot_type = 8
19+
20+
# The above types trigger 'TypeError: argument of type 'NoneType' is not iterable' which is addressed in issue #610
21+
is_available = v._is_mode_available(0)
22+
23+
v.close()

0 commit comments

Comments
 (0)