Can't access USB device in Universal App

此生再无相见时 提交于 2020-01-17 05:39:07

问题


I have a USB device that I have successfully set to use the WinUSB driver, and it shows up on the Raspberry Pi 2 startup screen as a connected device.

I have added it as a capability to the manifest:

<Capabilities>
  <Capability Name="internetClient" />
    <DeviceCapability Name="usb">
      <Device Id="vidpid:1234 abcd">
      <Function Type="classId:ff * *"/>
    </Device>
  </DeviceCapability>
</Capabilities>

Now I try to access it from my Universal App using the following code I found on MSDN:

string aqs = UsbDevice.GetDeviceSelector(0x1234, 0xabcd);
var myDevices = await DeviceInformation.FindAllAsync(aqs);
UsbDevice usbDevice = await UsbDevice.FromIdAsync(myDevices[0].Id);

The device is found as I can see it when I debug the myDevices variable, but the final line always throws the following exception:

Error HRESULT E_FAIL has been returned from a call to a COM component

Why? What can I do to remedy this and make it connect without errors?

来源:https://stackoverflow.com/questions/33764102/cant-access-usb-device-in-universal-app

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!