-
-
Notifications
You must be signed in to change notification settings - Fork 669
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
split polling can_read and reading from USB #4419
base: main
Are you sure you want to change the base?
Changes from 4 commits
e942f8e
51556ef
34559a4
c9188fb
7d9a53c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,7 +25,12 @@ async def read_message(iface: WireInterface, buffer: utils.BufferType) -> Messag | |
read = loop.wait(iface.iface_num() | io.POLL_READ) | ||
|
||
# wait for initial report | ||
report = await read | ||
msg_len = await read | ||
report = bytearray(msg_len) | ||
read_len = iface.read(report, 0, msg_len) | ||
if read_len != msg_len: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. these checks are kind of annoying... could we get rid of them somehow? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. how about this: 7d9a53c
|
||
print("read_len", read_len, "msg_len", msg_len) | ||
raise CodecError("Invalid length") | ||
if report[0] != _REP_MARKER: | ||
raise CodecError("Invalid magic") | ||
_, magic1, magic2, mtype, msize = ustruct.unpack(_REP_INIT, report) | ||
|
@@ -50,7 +55,11 @@ async def read_message(iface: WireInterface, buffer: utils.BufferType) -> Messag | |
|
||
while nread < msize: | ||
# wait for continuation report | ||
report = await read | ||
msg_len = await read | ||
report = bytearray(msg_len) | ||
read_len = iface.read(report, 0, msg_len) | ||
if read_len != msg_len: | ||
raise CodecError("Invalid length") | ||
if report[0] != _REP_MARKER: | ||
raise CodecError("Invalid magic") | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we also need to check that
offset
andlimit
are valid for thebuf
(and ideally raise a ValueError they exceed)
dtto webusb
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
solved as part of 7d9a53c, see below