mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-07-25 16:08:32 +00:00
make the var names in msg.py a bit less similar
This commit is contained in:
parent
4a255e8b77
commit
87145c2b5f
@ -39,19 +39,19 @@ def read_message():
|
|||||||
# TODO: validate msglen for sane values
|
# TODO: validate msglen for sane values
|
||||||
|
|
||||||
report = memoryview(report)
|
report = memoryview(report)
|
||||||
repdata = report[9:]
|
data = report[9:]
|
||||||
repdata = repdata[:msglen]
|
data = data[:msglen]
|
||||||
|
|
||||||
msgdata = bytearray(repdata) # TODO: allocate msglen bytes
|
msgdata = bytearray(data) # TODO: allocate msglen bytes
|
||||||
remaining = msglen - len(msgdata)
|
remaining = msglen - len(msgdata)
|
||||||
|
|
||||||
while remaining > 0:
|
while remaining > 0:
|
||||||
report = yield from read_report()
|
report = yield from read_report()
|
||||||
report = memoryview(report)
|
report = memoryview(report)
|
||||||
repdata = report[1:]
|
data = report[1:]
|
||||||
repdata = repdata[:remaining]
|
data = data[:remaining]
|
||||||
msgdata.extend(repdata)
|
msgdata.extend(data)
|
||||||
remaining -= len(repdata)
|
remaining -= len(data)
|
||||||
|
|
||||||
return (msgtype, msgdata)
|
return (msgtype, msgdata)
|
||||||
|
|
||||||
@ -65,15 +65,15 @@ def write_message(msgtype, msgdata):
|
|||||||
|
|
||||||
msgdata = memoryview(msgdata)
|
msgdata = memoryview(msgdata)
|
||||||
report = memoryview(report)
|
report = memoryview(report)
|
||||||
repdata = report[9:]
|
data = report[9:]
|
||||||
|
|
||||||
while msgdata:
|
while msgdata:
|
||||||
n = min(len(repdata), len(msgdata))
|
n = min(len(data), len(msgdata))
|
||||||
repdata[:n] = msgdata[:n]
|
data[:n] = msgdata[:n]
|
||||||
i = n
|
i = n
|
||||||
while i < len(repdata):
|
while i < len(data):
|
||||||
repdata[i] = 0
|
data[i] = 0
|
||||||
i += 1
|
i += 1
|
||||||
write_report(report)
|
write_report(report)
|
||||||
msgdata = msgdata[n:]
|
msgdata = msgdata[n:]
|
||||||
repdata = report[1:]
|
data = report[1:]
|
||||||
|
Loading…
Reference in New Issue
Block a user