-
Notifications
You must be signed in to change notification settings - Fork 3k
Add USB endpoint tests #6880
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
Add USB endpoint tests #6880
Conversation
The comments with test description are missing. I'll add them here or in the consecutive PR. |
|
I added the missing docstrings. |
TESTS/host_tests/pyusb_basic.py
Outdated
while time.time() < end_ts and not ctrl_error.is_set(): | ||
loopback_ep_test(ep_out, ep_in, ep_out.wMaxPacketSize) | ||
except usb.core.USBError as err: | ||
if err.errno not in (32, 110): |
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.
On windows this error is None
when the endpoint is stalled. You might need to remove this check if the error codes aren't portable.
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.
Done.
TESTS/host_tests/pyusb_basic.py
Outdated
while time.time() < end_ts: | ||
halt_ep_test(dev, bulk_out, bulk_in, bulk_out, log) | ||
bulk_out.clear_halt() | ||
intf.set_altsetting() # Force the device to start reading data from all OUT endpoints again. |
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.
I'm not sure if setting the alternate again is the right way to handle this, but I would like to get your thoughts on this @fkjagodzinski. Some possible alternatives
- Require that if a transfer was started then the transfer is resumed when halt is cleared (USBPhy responsible for this)
- Have the class driver handle the clear halt request and start the transfer again
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.
It was the simplest solution I was thinking about. I haven't thought about the test class callback for a clear request though. I'll update the code this way.
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.
I added VENDOR_TEST_READ_START
device request. It's used to explicitly start reading on given OUT endpoint.
TESTS/host_tests/pyusb_basic.py
Outdated
|
||
delayed_halt = Timer(delay, timer_handler) | ||
delayed_halt.start() | ||
end_ts = time.time() + 1.5 * delay |
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.
This delay wasn't long enough for my machine and caused intermittent failures. It may be good to set this to a really long delay (1 second?), as it will break from the loop early due to the stall anyway.
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.
Done, updated code does not use end_ts
at all.
TESTS/host_tests/pyusb_basic.py
Outdated
log('Testing aborting an in progress transfer for IN endpoints.') | ||
for ep_in in (bulk_in, interrupt_in): | ||
payload_size = (NUM_PACKETS_UNTIL_ABORT + NUM_PACKETS_AFTER_ABORT) * ep_in.wMaxPacketSize | ||
payload_in = ep_in.read(payload_size) |
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.
On my setup, Windows 10 using libusb-win32, this raises a timeout exception so payload_in
never gets returned:
USBError: [Errno None] libusb0-dll:err [_usb_reap_async] timeout error
Maybe instead of aborting and stopping the transfer, abort and start a new transfer with a buffer with different contents. Alternatively, this could be broken up into two reads, where the first one should complete fully, and the second one should timeout without any data.
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.
Done. Now reading data in chunks of wMaxPacketSize
each.
TESTS/host_tests/pyusb_basic.py
Outdated
|
||
if verbose: | ||
log('Testing OUT/IN data correctness for bulk endpoint pair.') | ||
for payload_size in range(1, bulk_out.wMaxPacketSize + 1): |
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.
Zero is a valid size, so it might not hurt to test that value as well. If you were seeing errors with this earlier #6922 should fix the errors.
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.
Updated; thanks for the reminder!
Umm... Is this PR still ongoing? #6884 is now closed... |
6464312
to
8fb7922
Compare
Update:
|
@c1728p9 Mind re-reviewing? |
675b24e
to
565ec75
Compare
This needs to be rebased but after that I will re-review. cc @fkjagodzinski |
8fb7922
to
ea32ceb
Compare
|
Endpoint callbacks no longer have endpoint as a param. This update was introduced in ARMmbed#7267.
After an endpoint is unstalled any pending transfers are terminated. This patch re-starts any reads that were ongoing.
Although the USB spec sets the upper limit on FS isochronous endpoint payloads to 1023 B, this value is hard to test in practice. Moreover, not all the targets Mbed OS supports (like NUCLEO_F207ZG) are able to handle all the endpoints set to max.
Wait for a locally created Timer thread to finish before returning.
1de5b2c
to
4759a20
Compare
4759a20
to
5b501e1
Compare
Validate that endpoint buffer is not used after a transfer has been aborted.
5b501e1
to
b1fdfd8
Compare
/morph build |
Build : SUCCESSBuild number : 2622 Triggering tests/morph test |
Exporter Build : SUCCESSBuild number : 2263 |
Test : FAILUREBuild number : 2371 |
/morph test |
Test : FAILUREBuild number : 2378 |
Test results same. We had similar failures 2 weeks ago (no space left on device error), @cmonr please review |
@studavekar FYI. Devices power cycled. Restarting. |
Test : SUCCESSBuild number : 2379 |
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.
Note, please run astyle for this feature branch once the work is done (might need to tweak astyleignore file))
Description
Extend
tests-usb_device-basic
with:endpoint test abort
,endpoint test data correctness
,endpoint test data toggle reset
,endpoint test halt
,endpoint test parallel transfers
,endpoint test parallel transfers ctrl
.Pull request type
CC @c1728p9 @maciejbocianski @jamesbeyond