Skip to content
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 Development+Testing section to README.md #101

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,18 @@ Class crates
* [usbd-hid](https://github.com/twitchyliquid64/usbd-hid) [![Crates.io](https://img.shields.io/crates/v/usbd-hid.svg)](https://crates.io/crates/usbd-hid) - HID class
* [usbd-serial](https://github.com/mvirkkunen/usbd-serial) [![Crates.io](https://img.shields.io/crates/v/usbd-serial.svg)](https://crates.io/crates/usbd-serial) - CDC-ACM serial port class

Development
-----------

### Testing

Testing `usb-device` involves a test suite running on a host computer, connected via USB to a target computer (microcontroller) which provides a test device. `usb-device` provides interfaces to hardware drivers, but it does not provide any hardware drivers, so external crates are required to run the test suite on specific hardware:

* [stm32-usbd-tests](https://github.com/Disasm/stm32-usbd-tests) and [usb-otg-workspace](https://github.com/Disasm/usb-otg-workspace) for STM32 parts.
* [test-usb-device](https://github.com/ianrrees/test-usb-device) for ATSAMD parts.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we instead just incorporate them as a member of the workspace here, so they don't get outdated?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe, that's partly what I'm wondering about in #100 .

I'd imagine the overwhelming majority of users of usb-device aren't going to be interested in this device-specific test code. As someone who spends more time tinkering with code that implements usb-device traits, rather than usb-device itself, I'd prefer to have the device-specific usb-device test code with whatever HAL it needs. That HAL already will have usb-device as a dependency, which I believe covers the versioning concerns.

That said, I think we could bring together the documentation from these usb-device test repos, because that's mostly about testing usb-device in general. I could imagine that documentation and test app expanding to cover other topics that might span multiple implementations of usb-device, for instance performance or feature sets.

Copy link
Member

@ryan-summers ryan-summers Aug 9, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The tests/ folder here isn't intended for users of usb-device, this is purely for CI and maintaince - as such, I don't think we should consider user concerns here.

While having device-specific code isn't the purpose of usb-device, we ultimately still need to verify the functionality of usb-device, which at this moment requires hardware. As such, I think having HITL (hardware-in-the-loop) test code situated here is a big bonus. This will give developers a platform to bring their own targets up for testing if they so require.

I worry that pointing to separate repos for the device-specific test code will result in the situation that we currently have in the future where the test code is lost and no one knows how to test :P

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The tests/ folder here isn't intended for users of usb-device, this is purely for CI and maintaince - as such, I don't think we should consider user concerns here.

My comment could've been written better. With "users". I was referring to both the people who would use usb-device (perhaps indirectly) in their projects, and people who are interested in changing/testing usb-device and code that interfaces with it. Maybe something like "consumers" and "developers" could be used for these two groups - I think we should keep both in mind.

I agree that the details of how testing works probably don't matter to the consumers, but think it is still important to not make things worse for them. Putting stuff in usb-device that won't be used by consumers is, to a small degree, making things worse for them - it's bloat that manifests in wasted bandwidth and disk. Part of the question is how that presumably-small impact to many people compares to the impact to a small number of developers.

I worry that pointing to separate repos for the device-specific test code will result in the situation that we currently have in the future where the test code is lost and no one knows how to test :P

The test code I made was a low-effort thing (in terms of usb-device) to support #60 - I knew basically how testing 'usb-device' worked at a technical level, my question about testing in #60 was more about expectations around testing proposed changes to 'usb-device'. That said, I knew how the testing technically worked because I'd looked at the test source code - the obvious room for improvement there is about improving documentation for testing usb-device.


Others
------

Other implementations for USB in Rust
* [embassy-usb](https://github.com/embassy-rs/embassy/blob/master/embassy-usb/src/driver.rs), an async variant.
* [embassy-usb](https://github.com/embassy-rs/embassy/blob/master/embassy-usb/src/driver.rs), an async variant.