nusb 0.2.3

Cross-platform low-level access to USB devices in pure Rust
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
//! Detach the kernel driver for an FTDI device and then reattach it.
use std::{thread::sleep, time::Duration};

use nusb::MaybeFuture;
fn main() {
    env_logger::init();
    let di = nusb::list_devices()
        .wait()
        .unwrap()
        .find(|d| d.vendor_id() == 0x0403 && d.product_id() == 0x6001)
        .expect("device should be connected");

    let device = di.open().wait().unwrap();
    device.detach_kernel_driver(0).unwrap();
    sleep(Duration::from_secs(10));
    device.attach_kernel_driver(0).unwrap();
}