1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
//! Raw USB device access.
//!
//! Provides device enumeration and raw bulk, control, and interrupt transfers
//! using [`nusb`](https://crates.io/crates/nusb) — a pure-Rust async USB
//! library with no system `libusb` dependency.
//!
//! ## Quick start
//!
//! ```rust,no_run
//! use brainwires_hardware::usb;
//!
//! // List all attached USB devices
//! #[tokio::main]
//! async fn main() -> anyhow::Result<()> {
//! let devices = usb::list_usb_devices();
//! for d in &devices {
//! println!(
//! "{} — {} {} ({})",
//! d.vid_pid(),
//! d.manufacturer.as_deref().unwrap_or("?"),
//! d.product.as_deref().unwrap_or("?"),
//! d.speed,
//! );
//! }
//!
//! // Open a specific device for raw transfers
//! // (replace VID/PID and interface number for your device)
//! let handle = usb::UsbHandle::open(0x046d, 0xc52b, 0).await?;
//!
//! // Bulk read 64 bytes from auto-detected IN endpoint
//! if let Some(ep) = handle.bulk_in_endpoint() {
//! use std::time::Duration;
//! let data = handle.bulk_read(Some(ep), 64, Duration::from_millis(500)).await?;
//! println!("Read {} bytes: {:?}", data.len(), &data[..data.len().min(16)]);
//! }
//! Ok(())
//! }
//! ```
//!
//! ## Permissions
//!
//! On Linux, USB device access typically requires either `root` or a `udev`
//! rule granting access to the device node (e.g. `SUBSYSTEM=="usb",
//! ATTR{idVendor}=="046d", MODE="0666"`).
//!
//! On macOS, no special permissions are needed for non-HID class devices.
//!
//! On Windows, a WinUSB-compatible driver must be installed for the target
//! device (e.g. via [Zadig](https://zadig.akeo.ie/)).
pub use ;
pub use UsbHandle;
pub use ;