1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-11-15 20:19:23 +00:00

fix(python): opportunistically catch a debuglink desync

In certain cases a DebugLinkState response can get stalled and debuglink
will not read it -- i.e., a situation analogous to wirelink de-sync.
There doesn't seem to be a good way to force-sync debuglink the same way
wirelink does it, but we can detect a wrong response to a
DebugLinkGetState and skip it.
This commit is contained in:
matejcik 2024-09-16 16:25:48 +02:00 committed by Martin Milata
parent d803a846a3
commit 93c6510b4b

View File

@ -521,6 +521,8 @@ class DebugLink:
self, wait_type: DebugWaitType = DebugWaitType.CURRENT_LAYOUT
) -> messages.DebugLinkState:
result = self._call(messages.DebugLinkGetState(wait_layout=wait_type))
while not isinstance(result, (messages.Failure, messages.DebugLinkState)):
result = self._read()
if isinstance(result, messages.Failure):
raise TrezorFailure(result)
return result