Add detach_claim example for testing

This commit is contained in:
Kevin Mehall 2024-01-30 09:02:58 -07:00
parent 6ded9244d0
commit 5aeca69d76

14
examples/detach_claim.rs Normal file
View file

@ -0,0 +1,14 @@
//! Detach the kernel driver for an FTDI device 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);
}