1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-12-15 19:08:07 +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 matejcik
parent a4bd771e3b
commit ef90546324

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