You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
RP2040 powered by USB AND an external power source.
Windows 11
Steps to reproduce
Deploy embassy's usb_raw example on the RP2040 with:
cd examples\rp
cargo run --release --bin usb_raw
Create a separate project with the main.rs and cargo.toml below. These are based on the nusb example from the usb_raw example documentation. Modifications are that
The control_in section has been removed.
block_on(interface.control_out {......}); has been replaced with interface.control_out_blocking(Control {...}, data, Duration::......);.
A loop {...} has been added around the control_out section.
Run the nusb code with cargo run.
Stop the nusb code.
Run the nusb code.
If it continues to work, repeat stop and re-run the nusb code until you start seeing errors.
Notice Err(Cancelled) output from the nusb code. Stop the nusb code.
With the RP2040 externally powered, disconnect and reconnect the USB cable.
Notice the "USB device not recognized" Windows notification.
nusb main.rs
use std::time::Duration;use futures_lite::future::block_on;use nusb::transfer::{Control,ControlIn,ControlOut,ControlType,Recipient};fnmain(){let di = nusb::list_devices().unwrap().find(|d| d.vendor_id() == 0xc0de && d.product_id() == 0xcafe).expect("no device found");let device = di.open().expect("error opening device");let interface = device.claim_interface(0).expect("error claiming interface");loop{// Send "hello world" to devicelet result = interface.control_out_blocking(Control{control_type:ControlType::Vendor,recipient:Recipient::Interface,request:100,value:200,index:0,},b"hello world",Duration::from_millis(1000));println!("{result:?}");}}
This may or may not be a bug in, or improper use of, nusb. However, I was expecting the following on the embassy side regardless of anything else.
It looks like this might be a bug causing the RP code to freeze or exit. The RP could be running (more or less) mission critical code apart from being a USB device. I expect other mission critical code to continue running. I have not checked if this is the case or not.
When I disconnect and reconnect the USB cable, I expect the device to reconnect, be recognized, and everything work.
Stopping the nusb code and restarting it just works (unless this is a bug in, or improper use of, nusb).
The text was updated successfully, but these errors were encountered:
Environment
Steps to reproduce
main.rs
andcargo.toml
below. These are based on the nusb example from the usb_raw example documentation. Modifications are thatblock_on(interface.control_out {......});
has been replaced withinterface.control_out_blocking(Control {...}, data, Duration::......);
.loop {...}
has been added around the control_out section.cargo run
.Err(Cancelled)
output from the nusb code. Stop the nusb code.nusb
main.rs
nusb
Cargo.toml
Expected behavior
This may or may not be a bug in, or improper use of, nusb. However, I was expecting the following on the embassy side regardless of anything else.
The text was updated successfully, but these errors were encountered: