1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-11-15 12:08:59 +00:00

transport_hid: fix buffer handling for Python 3

This commit is contained in:
Roman Zeyde 2016-05-05 20:48:10 +03:00 committed by Pavol Rusnak
parent 64fadde3e0
commit c567ceec94
No known key found for this signature in database
GPG Key ID: 91F3B339B9A02A3D

View File

@ -65,7 +65,7 @@ class HidTransport(Transport):
return False
def _open(self):
self.buffer = ''
self.buffer = bytearray()
self.hid = hid.device()
self.hid.open_path(self.device)
self.hid.set_nonblocking(True)
@ -75,7 +75,7 @@ class HidTransport(Transport):
def _close(self):
self.hid.close()
self.buffer = ''
self.buffer = bytearray()
self.hid = None
def ready_to_read(self):
@ -116,8 +116,8 @@ class HidTransport(Transport):
raise Exception("Not implemented")
# Payload received, skip the report ID
self.buffer += str(bytearray(data[1:]))
self.buffer.extend(bytearray(data[1:]))
ret = self.buffer[:length]
self.buffer = self.buffer[length:]
return ret
return bytes(ret)