embedded-trainings-2020/tools/usb-list/src/main.rs
Jorge Aparicio 75f41a47c4 - remove outdated notes
- VS: you can open more than one folder in the same VS workspace
- current folder in VS code needs to be set to beginner/apps for "Run" to appear
- rename `lsusb` to `usb-list`
- recommend `usb-list` over `lsusb`
- make `serial-term` behave like `screen`
2020-06-12 11:45:57 +02:00

27 lines
854 B
Rust

use std::error::Error;
fn main() -> Result<(), Box<dyn Error>> {
for dev in rusb::devices()?.iter() {
let desc = dev.device_descriptor()?;
let mut show_config = false;
let suffix = match (desc.vendor_id(), desc.product_id()) {
(0x1366, 0x1015) => " <- J-Link on the nRF52840 Development Kit",
(0x1915, 0x521f) => " <- nRF52840 Dongle (in bootloader mode)",
(0x2020, 0x0309) => " <- nRF52840 Dongle (loopback.hex)",
(consts::VID, consts::PID) => {
show_config = true;
" <- nRF52840 on the nRF52840 Development Kit"
}
_ => "",
};
println!("{:?}{}", dev, suffix);
if show_config {
let desc = dev.config_descriptor(0)?;
println!("> {:?}", desc);
}
}
Ok(())
}