1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-11-26 09:28:13 +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 M1nd3r
parent c22dc2ffc4
commit ede3c95c3f

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