Add detach_claim example for testing
This commit is contained in:
parent
6ded9244d0
commit
5aeca69d76
1 changed files with 14 additions and 0 deletions
14
examples/detach_claim.rs
Normal file
14
examples/detach_claim.rs
Normal 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);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue