1
votes

I use latest LibUsbDotNet nuget package in Visual Studio 2017 on Win 10. For my full speed USB device with 2 interrupt endpoints and 1 bulk IN endpoint I installed WinUSB driver using zadiq 2.4 utility.

LibUsbDotNet can see my device when UsbDevice.AllDevices is called.

However, it can't open my device using:

UsbDeviceFinder MyUsbFinder = new UsbDeviceFinder(VID, PID);
UsbDevice MyUsbDevice = UsbDevice.OpenUsbDevice(MyUsbFinder);

MyUsbDevice is null, no exception thrown.

I also tried to install different drivers (libusbk and libusb-win32), with no success.

Some time ago I coded an C++ app to communicate with my USB device using libusb library - and it works since then without any issue.

Is there anyone who can confirm that libusbdotnet is working product? I welcome any advice how to find what is wrong. Thanks.

2
Agreed, it's crazy! The LibUsbDotNet_Setup.2.2.8.exe download on sourceforge is 9 years old, and the active github project is what doesn't seem to work. I and apparently 22K other people have installed it via nuget, and it sure doesn't seem to be working to me and the samples are out of date (as of mid 2018/09). :/swooby

2 Answers

1
votes

This is a bug in UsbDeviceFinder, where int.MaxValue is used instead of null to ignore a value. This makes UsbDeviceFinder unusable and all examples that use it don't work.

The workaround is to use

MyUsbDevice = context.Find(device => device.ProductId == ProductId && device.VendorId == VendorId);

instead of

MyUsbDevice = context.Find(MyUsbFinder);

0
votes

First find your vendor id & product id by using device manager, input device , details then Hardware ID.

Next, You need to download LibUsbDotNet_Setup.2.2.8.exe and run setup. During setup you should enable filter and choose your input device per your vendor id. Then your code will find the device afterwards