我正在尝试从USB串口设备读取测试结果,下面的代码选择它连接到usb,所以我得到一个deviceInterface对象。但是现在当我使用UsbDevice.FromUsAsync时,它总是为空。
var selector = "System.Devices.InterfaceClassGuid:=\"" + "{GUID}";
var interfaces = await DeviceInformation.FindAllAsync(selector, null);
OutputText.Text = interfaces.Count + " device interface(s) found\n\n";
foreach (DeviceInformation deviceInterface in interfaces)
{
if (deviceInterface.Name == "CardioChek Link")
{
UsbDevice device = await UsbDevice.FromIdAsync(deviceInterface.Id);
if (device != null)
System.Diagnostics.Debug.WriteLine("FOUND!!!!!!!");
}
}
在应用程序清单中,我的配置看起来像这样:
<m2:DeviceCapability Name="serialcommunication">
<m2:Device Id="vidpid:0403 6001">
<m2:Function Type="name:serialPort"/>
</m2:Device>
</m2:DeviceCapability>
the device id = \\?\FTDIBUS#VID_0403+PID_6001+A60336ECA#0000#{4d36e978-e325-11ce-bfc1-08002be10318}
由于这个原因,我不得不将整个应用转换为桌面应用......