embedded-trainings-2020/advanced/host/print-descs/src/main.rs
Jorge Aparicio 886487dee6 - spread out USB information
- add intermediate-step solutions
- add more hints
- refactor exercise & text to have the same amount of work on all OSes
- add `usb` parser solutions
- make `dk-run` less silent
- rename rtic binaries (shorter names)
- link to the main svd2rust API docs
2020-06-30 19:02:21 +02:00

31 lines
1,013 B
Rust

use anyhow::anyhow;
fn main() -> Result<(), anyhow::Error> {
for dev in rusb::devices()?.iter() {
let dev_desc = dev.device_descriptor()?;
if dev_desc.vendor_id() == consts::VID && dev_desc.product_id() == consts::PID {
println!("{:#?}", dev_desc);
println!("address: {}", dev.address());
for i in 0..dev_desc.num_configurations() {
let conf_desc = dev.config_descriptor(i)?;
println!("config{}: {:#?}", i, conf_desc);
for iface in conf_desc.interfaces() {
println!(
"iface{}: {:#?}",
iface.number(),
iface.descriptors().collect::<Vec<_>>()
);
}
}
// TODO open the device; this will force the OS to configure it
// let mut handle = dev.open()?;
return Ok(());
}
}
Err(anyhow!("nRF52840 USB device not found"))
}