1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2025-08-05 13:26:57 +00:00
This commit is contained in:
M1nd3r 2025-03-24 12:37:32 +01:00
parent 90dd28f9b9
commit e793b5b79b
2 changed files with 12 additions and 3 deletions

View File

@ -36,6 +36,7 @@ from .client import (
MAX_PASSPHRASE_LENGTH,
MAX_PIN_LENGTH,
PASSPHRASE_ON_DEVICE,
Channel,
ProtocolVersion,
TrezorClient,
)
@ -1237,14 +1238,20 @@ class TrezorClientDebugLink(TrezorClient):
auto_interact: bool = True,
open_transport: bool = True,
debug_transport: Transport | None = None,
protocol: Channel | None = None,
) -> None:
try:
debug_transport = debug_transport or transport.find_debug()
self.debug = DebugLink(debug_transport, auto_interact)
if open_transport:
self.debug.open()
# try to open debuglink, see if it works
assert self.debug.transport.ping()
was_succ = self.debug.transport.ping()
if not was_succ:
self.debug = DebugLink(transport.find_debug(), auto_interact)
self.debug.open()
assert self.debug.transport.ping()
except Exception:
if not auto_interact:
self.debug = NullDebugLink()
@ -1255,7 +1262,7 @@ class TrezorClientDebugLink(TrezorClient):
transport.open()
# set transport explicitly so that sync_responses can work
super().__init__(transport)
super().__init__(transport=transport, protocol=protocol)
self.transport = transport
self.ui: DebugUI = DebugUI(self.debug)

View File

@ -49,7 +49,9 @@ class ProtocolV2Channel(Channel):
def read(self, session_id: int) -> t.Any:
sid, msg_type, msg_data = self.read_and_decrypt()
if sid != session_id:
raise Exception("Received messsage on a different session.")
raise Exception(
f"Received messsage on a different session (expected/received): ({session_id}/{sid}) "
)
return self.mapping.decode(msg_type, msg_data)
def write(self, session_id: int, msg: t.Any) -> None: