-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #65 from TheButlah/thebutlah/implement-detach
implement equivalent to libusb_detach_kernel_driver
- Loading branch information
Showing
5 changed files
with
97 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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() == 0x6001) | ||
.expect("device should be connected"); | ||
|
||
let device = di.open().unwrap(); | ||
device.detach_kernel_driver(0).unwrap(); | ||
sleep(Duration::from_secs(10)); | ||
device.attach_kernel_driver(0).unwrap(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters