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

Attempt at getting isochronous transfer working in rusb-async #217

Draft
wants to merge 56 commits into
base: rusb-async
Choose a base branch
from

Conversation

Aytixel
Copy link

@Aytixel Aytixel commented Feb 22, 2025

This PR is an attempt to get isochronous transfer working.

I already tested it with one of my project who needs it (at least on linux).
It should work on any os, but needs testing.

I'm well aware that the implementation is not perfect and I'd really like to get help to get it integrated.

Thanks for any suggestion or help on how to improve it.

The PR also solve this issue #160 making the Error and Result public.

ammubhave and others added 30 commits August 24, 2022 22:17
Make request_type function in fields.rs a const fn so that it can used
to create const global variables.

Test: The following code now compiles

```
const CTRL_OUT: u8 = request_type(
    rusb::Direction::Out,
    rusb::RequestType::Vendor,
    rusb::Recipient::Device,
);
```
fields.rs: Make request_type function a const fn
Before this commit, the lifetime of the endpoint descriptor was shorter
than the lifetime of the config descriptor, since it was tied to the
InterfaceDescriptor object. This commit amends the endpoint_descriptors
signature so that an EndpointDescriptor has the same lifetime as the
overarching ConfigDescriptor.

From my understanding, all state derived from a ConfigDescriptor has a
lifetime associated to that ConfigDescriptor. So, it's safe for the
EndpointDescriptor to adopt the ConfigDescriptor's lifetime through the
InterfaceDescriptor.

The new test shows us that the lifetimes are now all equal. This test
wouldn't compile without the signature change.
Increase endpoint descriptor's lifetime
Documentation specifies micros, but libusb consumes millis. Therefore passing in 1 micro results in an infinite timeout, not the shortest timeout.
…apability_descriptor

This fix adds missing fields to these two structs so that they can be
used from rust without the size mismatching from the C version.

See:
https://libusb.sourceforge.io/api-1.0/structlibusb__bos__descriptor.html
https://libusb.sourceforge.io/api-1.0/structlibusb__bos__dev__capability__descriptor.html
Add a function to disable device discovery
fix: 404 link for languages
Add serde support for public enums
rusb 0.9.3
Prepare release for rusb 0.9.3
Change the following methods to accept a non-exclusive reference:
- DeviceHandle::set_active_configuration
- DeviceHandle::unconfigure
- DeviceHandle::reset
- DeviceHandle::clear_halt
- DeviceHandle::detach_kernel_driver
- DeviceHandle::attach_kernel_driver
- DeviceHandle::set_auto_detach_kernel_driver
- DeviceHandle::claim_interface
- DeviceHandle::release_interface
- DeviceHandle::set_alternate_setting

This is safe to do because libusb is thread-safe.

Fixes a1ien#148
bLength, bDescriptorType and wTotalLength to descriptors
Use &self reference for all DeviceHandle methods
I and @dragonmux found two issues when building libusb from a MSVC host
to a MinGW target. When the build.rs script is built for the MSVC host,

- the vcpkg crate is used for detection (which correctly detects the
  MinGW target and reports an unsupported ABI)
- a MSVC flag is applied to the build (and thus breaking the build
  altogether)

This commit fixes both issues by changing vcpkg to a Windows-wide
dependency, and then if CARGO_CFG_TARGET_ENV is indeed MSVC, it is used
and the /source-charset:utf-8 flag is applied.
dmitry-zakablukov and others added 26 commits February 28, 2024 12:12
Some USB classes (UVC, UAC) provide alternate setting descriptors of interfaces with zero endpoints. Trying to call `endpoint_descriptors` on them caused a panic, because NULL was passed to `slice::from_raw_parts`. A branch was introduced to check for that case and create an iterator over an empty slice.

See: https://stackoverflow.com/a/49244874/2948315
…point-descriptors

fix: panic when trying to iterate over an interface with zero endpoints
Fix package detection and build when cross-compiling from MSVC to GNU
…iso_packet_desc (fixes a1ien#199)

This prevents panics on debug builds in new rust nightly versions (as of 2024-03-27), since they added bounds checks to `get_unchecked_mut`, which here was called on a zero-length slice representing a flexible array member. See: rust-lang/rust@2b43e75
Fixes a few macOS issues
Replace .get_unchecked_mut() with .as_mut_ptr().add() when accessing iso_packet_desc (fixes a1ien#199)
Add libusb_free_pollfds() in the available FFI methods.
…to-bos

fix: Add missing fields to libusb_bos_descriptor and libusb_bos_dev_capability_descriptor
libusb 0.7.0

* fix: Add missing fields to libusb_bos_descriptor and libusb_bos_dev_capability_descriptor
* Bump libusb to 1.0.27
* Remove unneeded mut

rusb 0.9.4

* bLength, bDescriptorType and wTotalLength to descriptors
* Use &self reference for all DeviceHandle methods
* fix: panic when trying to iterate over an interface with zero endpoints
* Log callback API added
* Bump libusb1-sys 0.7.0
Android does not have udev, but cross-compiling for Android on a Linux host with udev results in a udev link
Add libusb_init_context and associated structs
Android does not have udev; Do not link to udev on Android
Added new constructor for languages + tests
Co-authored-by: Ryan Butler <[email protected]>
Co-authored-by: Kevin Mehall <[email protected]>
@Aytixel Aytixel changed the title Attempt to get isochronous transfer working in rusb-async Attempt at getting isochronous transfer working in rusb-async Feb 22, 2025
@Aytixel Aytixel marked this pull request as draft February 22, 2025 22:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.