UWP SerialDevice.FromIdAsync 返回 null [英] UWP SerialDevice.FromIdAsync return null

查看:47
本文介绍了UWP SerialDevice.FromIdAsync 返回 null的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 Microsoft 串行端口示例,它可以在 Raspberry Pi2 上运行,但不能在本地机器上运行,在本地机器上返回 null.

I'm trying the Microsoft sample for Serial Port and it's working on Raspberry Pi2 but not on local machine , on,local machine return null.

已经添加了 DeviceCapability,这就是它在 Pi2 上工作的原因.

the DeviceCapability already added, that's why it's working on Pi2.

知道为什么它不能在本地机器上运行

any idea why it's not working on local machine

本地系统:Win10 Ent.VS 2015.3

local system: Win10 Ent. VS 2015.3

推荐答案

我找到了这个答案 :(

I found this answer :(

链接

系统内部或机箱上的串行端口可由 DeviceInformation.FindAllAsync() 枚举,但不能由 SerialDevice.FromIdAsync() 打开,因为它们当前不受支持.但是,支持通过 USB 连接的串行端口,例如 USB 转串行电缆.

System-internal or on-chassis serial ports may be enumerated by DeviceInformation.FindAllAsync(), but cannot be opened by SerialDevice.FromIdAsync() because they currently are not supported. However, serial ports connected over USB, such as on USB-to-Serial cables are supported.

更新:直到现在更新后问题仍然存在

Update : the issue still there even after the updates untill now

标记为机器内部的串行端口(DEVPKEY_Device_InLocalMachineContainer == TRUE) 不可访问除非供应商驱动程序明确标记为不受限制(DEVPKEY_DeviceInterface_Restricted == TRUE).设备通过大多数连接因此无法访问 PCI COM 端口扩展卡.

Serial ports marked as internal to the machine (DEVPKEY_Device_InLocalMachineContainer == TRUE) are not accessible unless explictly marked by the vendor driver as unrestricted (DEVPKEY_DeviceInterface_Restricted == TRUE). Devices connect via most PCI COM port expansion cards are therefore not accessible.

无法访问的串口仍可能被枚举DeviceInformation.FindAllAsync(),但不能被打开SerialDevice.FromIdAsync().试图打开这样的设备会要么抛出异常,要么返回 null.应用程序应该处理这种情况通过从用户的角度过滤此类串口,使用户将无法与此类不受支持的串行端口交互.

Inaccessible serial ports may still be enumerated by DeviceInformation.FindAllAsync(), but cannot be opened by SerialDevice.FromIdAsync(). Attemping to open such a device will either throw an exception or return null. Apps should handle this case by filtering such serial ports from the user's view, so that the user will not be able to interact with such an unsupported serial port.

这篇关于UWP SerialDevice.FromIdAsync 返回 null的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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