Skip to content

Commit

Permalink
pymavlink: fixed assumption that type(x) returns just the type
Browse files Browse the repository at this point in the history
it returns "<type 'bytearray'>" on some versions of python
  • Loading branch information
tridge committed Nov 4, 2015
1 parent 8f5b065 commit fc7ce0d
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions pymavlink/mavutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -760,10 +760,9 @@ def recv(self,n=None):

def write(self, buf):
try:
if type(buf) == 'str':
return self.port.write(buf)
if type(buf) == 'bytearray':
return self.port.write(str(buf))
if not isinstance(buf, str):
buf = str(buf)
return self.port.write(buf)
except Exception:
if not self.portdead:
print("Device %s is dead" % self.device)
Expand Down

0 comments on commit fc7ce0d

Please sign in to comment.