Repository navigation
usb.core: a read that times out keeps its transfer, so no packet is lost - #745
Merged
Merged
Conversation
With usbhost firmware that leaves a timed-out IN transfer armed, the default read's quarter-second steps and a raising timeout no longer cancel a transfer the device is filling. The docstring says so, and the tests pin that the default read rides through timeouts and returns a zero-length packet as 0.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Device.read()now says what happens to a read that times out on usbhost firmware that keeps the transfer armed (PyDevices/omnipython-builds#625). The transfer stays armed, the next read collects whatever the device sends, and a zero-length packet ends a read without a timeout and gives 0. On older firmware, a read that raises USBTimeoutError still cancels its transfer, and the docstring says so. The read code itself is unchanged: its 250 ms steps already raise and retry, and on the new firmware those steps no longer cancel anything.The fake
_usbhostin tests/test_usb_host_streams.py can now script reads. Two new tests check that a read with no timeout rides through timeouts in 250 ms steps and returns the packet, and that a zero-length packet ends it with 0 rather than another wait.python3 -m unittest tests.test_usb_host_streamspasses: 45 tests.On hardware, with omnipython-builds#625 on an ESP32-P4: before it, 32 KB flash drive reads with 1 ms raising timeouts lost 4.58 MB in 200 commands. With it, 1200 commands were byte-exact.
Fixes #742 together with PyDevices/omnipython-builds#625.