mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-11-23 07:58:09 +00:00
debuglink: fix debuglink for V2
This commit is contained in:
parent
c12bfc4add
commit
737200c7ef
@ -15,11 +15,13 @@ def pprint(msg):
|
||||
class DebugLink(object):
|
||||
def __init__(self, transport, pin_func=pin_info, button_func=button_press):
|
||||
self.transport = transport
|
||||
self.transport.session_begin()
|
||||
|
||||
self.pin_func = pin_func
|
||||
self.button_func = button_func
|
||||
|
||||
def close(self):
|
||||
self.transport.session_end()
|
||||
self.transport.close()
|
||||
|
||||
def _call(self, msg, nowait=False):
|
||||
|
@ -156,6 +156,9 @@ class TransportV1(Transport):
|
||||
|
||||
class TransportV2(Transport):
|
||||
def write(self, msg):
|
||||
if not self.session_id:
|
||||
raise Exception('Missing session_id for v2 transport')
|
||||
|
||||
data = bytearray(msg.SerializeToString())
|
||||
|
||||
# Convert to unsigned in python2
|
||||
@ -185,6 +188,9 @@ class TransportV2(Transport):
|
||||
first = False
|
||||
|
||||
def _read(self):
|
||||
if not self.session_id:
|
||||
raise Exception('Missing session_id for v2 transport')
|
||||
|
||||
chunk = self._read_chunk()
|
||||
(session_id, msg_type, datalen, data) = self.parse_first(chunk)
|
||||
payloadlen = datalen + 4 # For the checksum
|
||||
|
Loading…
Reference in New Issue
Block a user