mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-12-16 19:38:09 +00:00
src/trezor/wire: make sure the writes succeed
This commit is contained in:
parent
8f1ed5edce
commit
8ac915e75f
@ -1,7 +1,7 @@
|
|||||||
from micropython import const
|
from micropython import const
|
||||||
import ustruct
|
import ustruct
|
||||||
|
|
||||||
from trezor import io
|
from trezor import io, ui
|
||||||
from trezor import loop
|
from trezor import loop
|
||||||
from trezor import utils
|
from trezor import utils
|
||||||
|
|
||||||
@ -134,8 +134,11 @@ class Writer:
|
|||||||
|
|
||||||
if self.ofs == _REP_LEN:
|
if self.ofs == _REP_LEN:
|
||||||
# we are at the end of the report, flush it
|
# we are at the end of the report, flush it
|
||||||
await write
|
while True:
|
||||||
self.iface.write(self.data)
|
await write
|
||||||
|
n = self.iface.write(self.data)
|
||||||
|
if n == len(self.data):
|
||||||
|
break
|
||||||
self.ofs = _REP_CONT_DATA
|
self.ofs = _REP_CONT_DATA
|
||||||
|
|
||||||
return nwritten
|
return nwritten
|
||||||
@ -149,5 +152,9 @@ class Writer:
|
|||||||
self.data[self.ofs] = 0x00
|
self.data[self.ofs] = 0x00
|
||||||
self.ofs += 1
|
self.ofs += 1
|
||||||
|
|
||||||
await loop.select(self.iface.iface_num() | io.POLL_WRITE)
|
write = loop.select(self.iface.iface_num() | io.POLL_WRITE)
|
||||||
self.iface.write(self.data)
|
while True:
|
||||||
|
await write
|
||||||
|
n = self.iface.write(self.data)
|
||||||
|
if n == len(self.data):
|
||||||
|
break
|
||||||
|
Loading…
Reference in New Issue
Block a user