a1ien / rusb

A safe Rust wrapper for libusb.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

open_device_with_vid_pid not working as expected

Darkskald opened this issue · comments

I tried to call the Context method open_device_with_context with a vendor id and product id from which I know that they are present, but calling the method yields None.

When iterating over the devices:

fn main() {
    let context = Context::new().unwrap();
    let devices = context.devices().unwrap();
    for device in devices.iter(){
        println!("{:?}", device.device_descriptor().unwrap());
    }
}

I see

DeviceDescriptor { bLength: 18, bDescriptorType: 1, bcdUSB: 512, bDeviceClass: 0, bDeviceSubClass: 0, bDeviceProtocol: 0, bMaxPacketSize: 64, idVendor: 3768, idProduct: 59906, bcdDevice: 0, iManufacturer: 1, iProduct: 2, iSerialNumber: 3, bNumConfigurations: 1 }
``

but calling

```rust
let mut handle = context.open_device_with_vid_pid(3768, 59906);

yields None.

In order to open the device you would need the proper permissions and, possibly, drivers installed. This can be different depending on the OS you're trying this on.

Please check that you use proper driver and have correct permission. Also check this https://github.com/libusb/libusb/wiki/Windows#how-to-use-libusb-on-windows if you use rusb on windows