| 1 | //! Detach the kernel driver for an FTDI device and then reattach it. |
| 2 | use std::{thread::sleep, time::Duration}; |
| 3 | fn main() { |
| 4 | env_logger::init(); |
| 5 | let di = nusb::list_devices() |
| 6 | .unwrap() |
| 7 | .find(|d| d.vendor_id() == 0x0403 && d.product_id() == 0x6001) |
| 8 | .expect("device should be connected"); |
| 9 | |
| 10 | let device = di.open().unwrap(); |
| 11 | device.detach_kernel_driver(0).unwrap(); |
| 12 | sleep(Duration::from_secs(10)); |
| 13 | device.attach_kernel_driver(0).unwrap(); |
| 14 | } |