Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UWP app cannot find/connect to USB device

Tags:

usb

uwp

I am trying to make a UWP app which connects to a USB device and then executes a series of commands, like retrieving data from the internal sensor (think of an accelerometer). I started of with following these guidelines:

https://msdn.microsoft.com/en-us/library/windows/hardware/dn303343(v=vs.85).aspx

So, I also tried making a blank app, and adjusted the manifest accordingly:

<Capabilities>
  <DeviceCapability Name="usb">
    <Device Id="vidpid:1CBE 0003">
      <Function Type="classId:ff 00 00" />
    </Device>
  </DeviceCapability>
</Capabilities>

To be sure, this is how the device identifies itself in the device manager:

it's a WinUSB devicevendor and product ID are setclass ID is set to FF 00 00

and then used

string aqs = UsbDevice.GetDeviceSelector(vid, pid);
var finder = await DeviceInformation.FindAllAsync(aqs);

However, without success. The problem is simple, the app cannot find any device. I then went on to modify this sample app (which uses a DeviceWatcher instead of above way of finding a connected device USB):

https://github.com/Microsoft/Windows-universal-samples/tree/master/Samples/CustomUsbDeviceAccess

which also did not find a USB device. Of course I tried a different PC to see if it is related to my configuration, but as you expected, no success. This led me to think that it might be related to the USB device, but what could be wrong? Or did I really make some mistake in these five lines? Is there another way I could try to connect to the USB device? Any hint is appreciated!

Related Questions:

UWP/C# - Issue with AQS and USB Devices

https://social.msdn.microsoft.com/Forums/en-US/e9b85e2a-27c0-489e-9bf5-d990f0e83a61/uwpissue-with-usbdevicegetdeviceselector-not-finding-attached-bulk-usb-device?forum=wpdevelop

like image 283
Dr.J Avatar asked Dec 12 '16 08:12

Dr.J


Video Answer


1 Answers

It seems that I found one way to resolve this, which is a bit stupid, but hey, who asks me anyway...

I came across this one here on stackoverflow: Cannot create UsbDevice from DeviceInformation.Id

And it seems that my issue is indeed resolved when I use a .inf to refer to winusb as the driver. I have no idea why, so if any of you have an explanation, please let me know.

As above answer is referring to a blogpost that does exist anymore (I used the wayback machine to get to it), I'm posting the inf here, in case it helps anyone (but it's an ordinary inf)

;
;
; Installs WinUsb
;

[Version]
Signature = "$Windows NT$"
Class     = USBDevice
ClassGUID = {88BAE032-5A81-49f0-BC3D-A4FF138216D6}
Provider  = %ManufacturerName%
CatalogFile = WinUSBInstallation.cat
DriverVer=12/12/2016,13.54.20.543

; ========== Manufacturer/Models sections ===========

[Manufacturer]
%ManufacturerName% = Standard,NTamd64

[Standard.NTamd64]
%DeviceName% =USB_Install, USB\VID_1267&PID_0000

; ========== Class definition ===========

[ClassInstall32]
AddReg = ClassInstall_AddReg

[ClassInstall_AddReg]
HKR,,,,%ClassName%
HKR,,NoInstallClass,,1
HKR,,IconPath,%REG_MULTI_SZ%,"%systemroot%\system32\setupapi.dll,-20"
HKR,,LowerLogoVersion,,5.2

; =================== Installation ===================

[USB_Install]
Include = winusb.inf
Needs   = WINUSB.NT

[USB_Install.Services]
Include =winusb.inf
Needs   = WINUSB.NT.Services

[USB_Install.HW]
AddReg=Dev_AddReg

[Dev_AddReg]
HKR,,DeviceInterfaceGUIDs,0x10000,"{9f543223-cede-4fa3-b376-a25ce9a30e74}"

; [DestinationDirs]
; If your INF needs to copy files, you must not use the DefaultDestDir         directive here.  
; You must explicitly reference all file-list-section names in this     section.

; =================== Strings ===================

[Strings]
ManufacturerName=""
ClassName="Universal Serial Bus devices"
DeviceName="OWI-535 Robotic Arm"
REG_MULTI_SZ = 0x00010000

Note that I left an arbitrary VID and PID in the driver, but I still have to connect with the VID and PID that the device tells me.

like image 56
Dr.J Avatar answered Oct 06 '22 22:10

Dr.J