File: detach_claim.rs

package info (click to toggle)
rust-nusb 0.1.13-1
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 548 kB
  • sloc: makefile: 2
file content (15 lines) | stat: -rw-r--r-- 511 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
//! Detach the kernel driver for an FTDI device, claim the USB interface, and
//! then reattach it.
use std::{thread::sleep, time::Duration};
fn main() {
    env_logger::init();
    let di = nusb::list_devices()
        .unwrap()
        .find(|d| d.vendor_id() == 0x0403 && d.product_id() == 0x6010)
        .expect("device should be connected");

    let device = di.open().unwrap();
    let interface = device.detach_and_claim_interface(0).unwrap();
    sleep(Duration::from_secs(1));
    drop(interface);
}