a1ien / rusb

A safe Rust wrapper for libusb.
Other
382 stars 78 forks source link

read_device.rs example ejected USB flash drive #192

Closed weiying-chen closed 2 months ago

weiying-chen commented 6 months ago

I compiled the read_device.rs example and ran it with sudo on Ubuntu:

❯ sudo ./target/debug/usb 0x13fe 0x6700
Active configuration: 1
Languages: [Language { raw: 1033 }]
Manufacturer: Some("        ")
Product: Some("USB DISK 3.0")
Serial Number: Some("9000358C098BEB69")
No readable interrupt endpoint
Reading from endpoint: Endpoint { config: 1, iface: 0, setting: 0, address: 129 }
 - kernel driver? true
could not read from endpoint: Operation timed out

It seems like the command worked but stopped halfway? Why was my USB flash drive ejected?

alufers commented 3 months ago

Usually for a USB pendrive to be shown in the system as a disk a kernel driver exists, which converts the block device operations into the lower-level USB transactions. However by running this example you detached the kernel driver from it (https://github.com/a1ien/rusb/blob/master/examples/read_device.rs#L162 ) , so that rusb can talk to it directly.

As to why it failed: Probably the controller in the pendrive got confused and got reset or bugged out.