-
Notifications
You must be signed in to change notification settings - Fork 3k
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 HID tests #10096
Add USB HID tests #10096
Conversation
requirements.txt
Outdated
@@ -23,4 +23,5 @@ git+https://github.com/armmbed/[email protected] | |||
icetea>=1.2.1,<1.3 | |||
pycryptodome>=3.7.2,<=3.7.3 | |||
pyusb>=1.0.0,<2.0.0 | |||
hidapi>=0.7.99,<0.8.0 |
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.
@c1728p9, @jamesbeyond I'd like to clarify the licensing of this module. Based on its LICENSE file it can be used under one of 3 licenses. Should I specify, which one we want to use? If so, how do I do that?
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.
@0xc0170 Might be a question for you as well
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 need more context here, one of 3 licenses? Does this module hidapi have dual license or?
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.
Yes 3
cython-hidapi may be used by one of three licenses as outlined in LICENSE.txt
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.
Got it . This is missing in our license file (capturing python dependencies there!) , can you fix that ? IT would be added there as well - hidapi under BSD license
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.
Created #10123
@fkjagodzinski, thank you for your changes. |
I can see Travis CI failed when installing the @0xc0170 @cmonr How can I add the missing prerequisites to the travis config? Or should we avoid introducing such modification just to be able to run one test case? (Currently, all USB tests are skipped on the CI anyway.) I can update the python code to handle the import failure and skip this test case. |
2f97c22
to
a845863
Compare
OK, with a temporary fix, tests also work on Windows hosts. I'll prepare a proper fix shortly. |
Oh jeez, this just got really nasty really quick. if I understand correctly, the new python module also requires additional system packages? |
Yeah, this is not ideal, but applies only to Linux users. I can see two possible solutions here:
The second option seems better, but has a drawback -- the host side HID driver will be excluded, making the test less valuable. USB transfers through @c1728p9 what do you think? |
TESTS/usb_device/hid/main.cpp
Outdated
usb_hid.connect(); | ||
greentea_send_kv(MSG_KEY_TEST_RAW_IO, REPORT_SIZE); | ||
usb_hid.wait_ready(); | ||
wait_ms(500); |
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.
Why the 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.
I added that temporarily to handle host side driver setup. It turned out to take much longer on Windows than Linux. It is replaced with a greentea_parse_kv()
now.
Hi @fkjagodzinski I would prefer to go with option 1 - make the test optional on linux. As you mentioned, I don't think pyusb will add much testing value as it bypasses the host's driver. @donatieng what do you think? |
CC @bulislaw |
a845863
to
8c6f63e
Compare
The PR is ready for review again. Latest updates provide:
|
@c1728p9, @jamesbeyond, @maciejbocianski Can we get this re-reviewed please? |
The first 4 bytes received were lost due to a wrong address. Read the output report into HID_REPORT.data.
To successfully use pyusb on Windows hosts, a Zadig configuration has to be performed. Since config for basic tests has already been provided, use it again.
Wait for the host driver to finish setup before sending any HID reports from the device. USBHID::wait_ready() blocks until the device reaches 'configured' state, but the state of the host HID driver remains unknown to the device.
Every test case waits at greentea_parse_kv() anyway.
This test case uses `hidapi` -- a cross-platform Python module. To keep the initial Mbed setup as simple as possible, the `hidapi` module is skipped on Linux hosts because of its external dependancies for this platform. The module can be easily installed following instructions from the README file. The test case is skipped if the host machine lacks `hidapi` module.
e7021b2
to
491ea55
Compare
I've rebased the commits onto current master and fixed the |
CI started |
Test run: FAILEDSummary: 2 of 11 test jobs failed Failed test jobs:
|
I've checked the errors; they're unrelated to this PR.
|
Tests restarted |
CI job restarted: |
Test run: SUCCESSSummary: 11 of 11 test jobs passed |
Description
Add
tests-usb_device-hid
test suite forUSBHID
,USBMouse
&USBKeyboard
.Pull request type
Reviewers
@c1728p9, @jamesbeyond, @maciejbocianski
Release Notes