Commit graph

225 commits

Author SHA1 Message Date
Kevin Mehall
a34c4497b7
Merge pull request #102 from kirisauce/dev
Add support for getting device descriptor and speed from opened device
2025-01-19 23:10:31 -07:00
Kevin Mehall
4871f227a0 Fix existing warnings 2025-01-19 22:09:39 -07:00
Kevin Mehall
0e8c9f59f4 Add DeviceDescriptor::as_bytes 2025-01-19 21:04:16 -08:00
Kevin Mehall
8e4caaa5b2 Use Device::device_descriptor in string_descriptors example 2025-01-19 21:00:03 -08:00
Kevin Mehall
9a93ca796d Wrap DeviceDescriptor string index fields in Option 2025-01-19 20:59:05 -08:00
Kevin Mehall
9c98f2bd32 Implement Device::{device_descriptor, speed} on macOS 2025-01-19 20:47:37 -08:00
Kevin Mehall
55072d40e7 Implement Device::{device_descriptor, speed} on Windows 2025-01-19 19:32:25 -07:00
Kevin Mehall
de5771030c Simplify Device::speed API
We'll log if the ioctl failed, but there's probably not a use case to
determine why it failed to justify Result<Option<>>. It'll be
infallible (besides unknown values) on other platforms.
2025-01-19 19:03:06 -07:00
Kevin Mehall
c6f2812671 Make DeviceDescriptor contain a fixed size array
Unlike the Configuration descriptor, it does not contain nested
descriptors.

It's also made infallible, because the kernel wouldn't enumerate
the device without it.
2025-01-19 19:01:15 -07:00
kirisauce
5a7a4be0cf Linux: Support getting device speed from the kernel
This is done through an ioctl `USBDEVFS_GET_SPEED`. Judging from
the kernel souce code, it just returns a cached value, and should
not make any request to the device.
2025-01-13 22:58:12 +08:00
kirisauce
2c6a6d3758 Linux: Support getting DeviceDescriptor and DeviceInfo from a opened device 2025-01-08 13:13:19 +08:00
kirisauce
91fe523d76 Add DeviceDescriptor type for parsing device descriptors 2025-01-08 13:13:19 +08:00
Kevin Mehall
0dc8aa5fe8
Merge pull request #105 from kevinmehall/windows-hotplug-send-sync
impl Send + Sync for HotplugWatch
2025-01-05 23:17:49 -07:00
Kevin Mehall
c59e0fe7ec macos: impl Sync for HotplugWatch 2025-01-05 23:13:19 -07:00
Kevin Mehall
2f7336ed2d windows: impl Send + Sync for HotplugWatch 2025-01-05 23:13:00 -07:00
Kevin Mehall
b167c7e744 Breaking changes on main, set version to 0.2.0-beta 2024-12-27 12:47:00 -07:00
Kevin Mehall
3c8ba0a1aa Fix race condition that could lose a transfer completion wakup
If `poll_completion_generic` runs between `notify_completion`'s
`waker.take()` and `state.swap(STATE_COMPLETED, ...)`, it could see the
transfer as pending and register its waker, but that waker would never
be called.

This adds an Arc because once the transfer is set to `STATE_COMPLETED`,
the other thread might free it, so we need to ensure the AtomicWaker
stays alive while we use it. That's what the `take()` was intended
to work around, but reading the waker before writing the status
introduces the race.
2024-11-19 22:29:06 -07:00
Kevin Mehall
6562dd97e9 Update docs for windows serial number fix (4ddd81b) 2024-11-16 14:43:10 -07:00
Kevin Mehall
f8f23b2b4c
Merge pull request #88 from kevinmehall/macos-fix
macOS: Fix set_configuration and reset by using USBDeviceOpen
2024-10-30 09:20:53 -06:00
Kevin Mehall
ce3a29e820 macOS: prevent reset and set_configuration while an interface is claimed 2024-10-27 22:21:14 -06:00
Kevin Mehall
2f87736856 macOS: Fix set_configuration and reset by using USBDeviceOpen 2024-10-27 22:21:00 -06:00
Kevin Mehall
3d45e26452 macos: Fix detection of TransferError::Stall 2024-10-27 22:18:53 -06:00
Kevin Mehall
b3097f552a
Merge pull request #85 from tuna-f1sh/win-hub-devices
Windows: include hub devices in list like other platforms
2024-10-19 15:06:03 -06:00
John Whittington
785e89ab21 win: include hub devices in list like other platforms 2024-10-14 09:16:40 +02:00
Kevin Mehall
809228038f
Merge pull request #77 from tuna-f1sh/root_hub
List root hubs function
2024-09-28 11:26:47 -06:00
Kevin Mehall
4774c75c2c Remove dead code 2024-09-28 11:24:40 -06:00
John Whittington
060f284255 add getters for android; note that list_buses requires root 2024-09-27 07:20:07 +02:00
John Whittington
f4f3719387 macos: tidy list_buses now passed hci_type 2024-09-27 06:27:48 +02:00
John Whittington
1ffba0caa7 macos: return usb_service_iter to main 2024-09-24 10:59:00 +02:00
John Whittington
c7d28f8128 untested android support 2024-09-23 14:04:57 +02:00
John Whittington
d8b1f10a6f prevent unsafe function by passing UsbControllerType 2024-09-23 13:34:04 +02:00
John Whittington
f86952c27b remove bus_id example filter 2024-09-23 13:34:04 +02:00
John Whittington
a4d48926d8 windows: just check starts with root_hub 2024-09-23 13:34:04 +02:00
John Whittington
dfa821b391 Update src/platform/linux_usbfs/enumeration.rs
Co-authored-by: Martin Ling <martin-github@earth.li>
2024-09-23 13:34:04 +02:00
Martin Ling
b3917aa8fd Avoid nested use of Iterator::chain(). 2024-09-23 13:34:04 +02:00
Martin Ling
c9822becc3 Replace .map() + .flatten() with .and_then() 2024-09-23 13:34:04 +02:00
John Whittington
66851159e0 windows: remove now unused host controller parsing 2024-09-23 13:34:04 +02:00
John Whittington
b607a9b370 add grabbed parent path on Linux and Windows 2024-09-23 13:34:04 +02:00
John Whittington
b4959da4f6 remove pci_info and struct 2024-09-23 13:34:04 +02:00
John Whittington
d0b37bb13d mac: and_then not flatten, note on IONameMatch 2024-09-23 13:34:04 +02:00
John Whittington
9bdf07468e win: probe parent service for concrete controller_type 2024-09-23 13:34:04 +02:00
John Whittington
60076e6e4b tidy linux readlink and parent_path 2024-09-23 13:34:04 +02:00
John Whittington
86949627a2 add system_name for all platforms 2024-09-23 13:34:04 +02:00
John Whittington
5a4ee26e6b pr feedback 2024-09-23 13:34:04 +02:00
John Whittington
a0ed0ced0c rename UsbController; parse from instance_id on Win 2024-09-23 13:34:04 +02:00
John Whittington
602cfb0685 macos: add CFData parsing of revision and name 2024-09-23 13:34:04 +02:00
John Whittington
c7675914ae a more applied doc list_buses example 2024-09-23 13:34:04 +02:00
John Whittington
d4e12206ec specific BusInfo type for 'root hubs'
root hubs are a Linuxism - an abstract USB device capturing
information about a system USB bus; connected to a Host Controller.  Bus
data is useful for system profiling so a BusInfo type is added to crate
a more portable 'root hub' type.

Considering whether to use a HostControllerInfo highlighted the place
for root hubs. There can be multiple system USB buses on a Host
  Controller Interface (HCI), so it makes sense to have a separate type.
  Multiple buses can share the same PciInfo for example because they sit
  on the same HCI.
2024-09-23 13:34:04 +02:00
John Whittington
ae98f5c069 tidy and remove unused get_hub_info 2024-09-23 13:34:04 +02:00
John Whittington
e709abe41c attempt to get other Apple HCI 2024-09-23 13:34:04 +02:00