UWP 应用无法找到/连接到 USB 设备 [英] UWP app cannot find/connect to USB device

查看:29
本文介绍了UWP 应用无法找到/连接到 USB 设备的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试制作一个 UWP 应用程序,该应用程序连接到 USB 设备,然后执行一系列命令,例如从内部传感器检索数据(想想加速度计).我开始遵循以下准则:

其中也没有找到 USB 设备.当然我尝试了不同的PC,看看它是否与我的配置有关,但正如您所料,没有成功.这让我想到它可能与 USB 设备有关,但有什么问题呢?还是我真的在这五行中犯了一些错误?还有其他方法可以尝试连接到 USB 设备吗?任何提示表示赞赏!

相关问题:

UWP/C# - AQS 和 USB 设备问题

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

解决方案

看来我找到了解决这个问题的方法,有点笨,但是嘿嘿,反正谁问我...

我在 stackoverflow 上遇到了这个:无法从 DeviceInformation.Id 创建 UsbDevice

当我使用 .inf 将 winusb 称为驱动程序时,似乎确实解决了我的问题.我不知道为什么,所以如果你们有任何解释,请告诉我.

因为上面的答案是指已经存在的博客文章(我使用了回程机器来获取它),我在这里发布 inf,以防它对任何人有帮助(但它是一个普通的 inf)

<代码>;;;安装 WinUsb;[版本]签名 = "$Windows NT$"类 = USBDeviceClassGUID = {88BAE032-5A81-49f0-BC3D-A4FF138216D6}提供者 = %ManufacturerName%CatalogFile = WinUSBInstallation.catDriverVer=12/12/2016,13.54.20.543;========== 制造商/型号部分 ============[制造商]%ManufacturerName% = 标准,NTamd64[标准.NTamd64]%DeviceName% =USB_Install, USB\VID_1267&PID_0000;========== 类定义 ============[ClassInstall32]AddReg = ClassInstall_AddReg[ClassInstall_AddReg]HKR,,,,%ClassName%HKR,,NoInstallClass,,1HKR,,IconPath,%REG_MULTI_SZ%,"%systemroot%\system32\setupapi.dll,-20"HKR,,LowerLogoVersion,,5.2;================== 安装 ====================[USB_安装]包含 = winusb.inf需要 = WINUSB.NT[USB_Install.Services]包括=winusb.inf需要 = WINUSB.NT.Services[USB_Install.HW]AddReg=Dev_AddReg[Dev_AddReg]HKR,,DeviceInterfaceGUIDs,0x10000,"{9f543223-cede-4fa3-b376-a25ce9a30e74}";[目的地目录];如果您的 INF 需要复制文件,则不得在此处使用 DefaultDestDir 指令.;您必须显式引用本节中的所有文件列表节名称.;================== 字符串 ====================[字符串]制造商名称=""ClassName="通用串行总线设备"DeviceName="OWI-535 机械臂"REG_MULTI_SZ = 0x00010000

请注意,我在驱动程序中留下了任意 VID 和 PID,但我仍然需要连接设备告诉我的 VID 和 PID.

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:

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

解决方案

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.

这篇关于UWP 应用无法找到/连接到 USB 设备的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆