ch32-rs / wlink

An open source WCH-Link library/command line tool written in Rust.
Apache License 2.0
155 stars 25 forks source link

Misleading error message on error from Rusb #50

Closed pdietl closed 6 months ago

pdietl commented 6 months ago

I don't know enough Rust to understand how to fix it. When attempting to run wlink status, I kept getting the error message

Error: WCH-Link not found, please check your connection

I eventually figured out that it was because I neglected to setup a udev rule for the DAP mode of the WCH-Link. I dove into the code and tracked down the failure to here: https://github.com/ch32-rs/wlink/blob/main/src/usb_device.rs#L116

Using rust-gdb to step deeper, indeed libusb was returning error code -3, meaning permission denied.

I see in errors.rs that this https://github.com/ch32-rs/wlink/blob/main/src/error.rs#L12-L13 is a thing, but somehow this USB error gets converted into ProbeNotFound.

pdietl commented 6 months ago

Nvm somehow it works an I was confused :sweat_smile: