Cannot create UsbDevice from DeviceInformation.Id

2

I'm trying to connect to a device (SecuGen Hamster Pro 20) through Windows.Devices.Usb APIs using Universal Windows App for PC only (no phones)(WinRT).

The device is a fingerprint scanner.

I've done all the steps found online to do that:

I've looked for all devices using:

var myDevices = await Windows.Devices.Enumeration.DeviceInformation.FindAllAsync();

This returns about 1400 devices. After some filteration using:

 var resultList = myDevices.Where(s => s.Name.ToLower().Contains("secu")).ToList<DeviceInformation>();

resultList contains 3 devices in my machine (I've tried it on other machine and found 10 results on some).

I didn't use the overload for finding devices DeviceInformation.FindAllAsync(String aqsFilter) because it returns 0 results althought I'm sure I've done it right (used correct VID & PID)

The problem here is when I try to create a UsbDevice object from any of the 3 results using:

UsbDevice device = await UsbDevice.FromIdAsync(resultList[0].Id);

The return value is null, I've tried all of them (resultList[0] , resultList[1] , resultList[2]) with no luck.

I configured the capabilities using:

 <DeviceCapability Name="usb">
      <Device Id="vidpid:1162 2200">
        <Function Type="name:vendorSpecific"/>
      </Device>
    </DeviceCapability> 

I also tried to create a UsbDevice object from any of the 1400 devices returned from DeviceInformation.FindAllAsync() but all returned null and even some throw an exception that says the system cannot find the file specified 0x80070002

I tried to read DeviceAccessInformation for the device it returned DeviceAccessStatus.Unspecified

Anyone can lead me to what am I missing here?

c#
windows-runtime
usb
win-universal-app
hardware
asked on Stack Overflow May 11, 2016 by user3448868

2 Answers

1

You have to use UsbDevice.GetDeviceSelector and then use the selector when searching for the device. If that returns nothing, then the device isn't properly 'configured' to use the WinUSB.sys driver. (And from what I understand, it must use that driver to be used with the usbdevice class).

If you manually told it to use that driver in the device manager, then, in theory, you still have to change a key with regedit before that works (Note: I did that and it still wouldn't work). I found a solution that solved it here: http://www.lewisbenge.net/2013/09/20/integrating-windows-8-1-with-owi-535-robotic-arm/ Basically, you have to install the driver using an inf file. use the one linked on that site and replace the NTamd64 with NTarm depending on the target platform

answered on Stack Overflow May 25, 2016 by Samuel
0

Firstly, try to narrow down your search by vendor and product Id

This method will help you do that:

public static async Task<List<wde.DeviceInformation>> GetDevicesByProductAndVendorAsync(int vendorId, int productId)
{
    return ((IEnumerable<wde.DeviceInformation>)await wde.DeviceInformation.FindAllAsync($"System.Devices.InterfaceEnabled:=System.StructuredQueryType.Boolean#True AND System.DeviceInterface.Hid.VendorId:={vendorId} AND System.DeviceInterface.Hid.ProductId:={productId} ").AsTask()).ToList();
}

https://github.com/MelbourneDeveloper/Hid.Net/blob/c69e3368343e59e51e8818c87dbea00e6ccfecae/Hid.Net.UWP/UWPHelpers.cs#L11

You will be able to get a list of connected devices from that. You should then be able to connect with FromIdAsync.

answered on Stack Overflow Nov 25, 2018 by Christian Findlay

User contributions licensed under CC BY-SA 3.0