是否可以将 PnpObjectType_DeviceInterface 添加到 UWP Package.appxmanifest <DeviceCapability>?
Is it possible to add PnpObjectType_DeviceInterface to UWP Package.appxmanifest <DeviceCapability>?
我的 Win32 应用程序通常通过 USB 接口与串行设备通信。多年来,出于诊断和开发目的,我一直使用创建串行环回接口的 Com0Com 实用程序。我现在正在编写我的应用程序的 UWP(非商店)版本。
Com0Com端口在调用时可见
// Construct AQS String for all serial devices on system
Platform::String ^serialDevices_aqs = Windows::Devices::SerialCommunication::SerialDevice::GetDeviceSelector();
// Identify all paired devices satisfying query
return Windows::Devices::Enumeration::DeviceInformation::FindAllAsync(serialDevices_aqs);
添加查看从我获取的串行设备列表中获取的 com0com 端口的 device_ID 值
[Id] = L"\\?\com0com#port#CNCA1#{86e0d1e0-8089-11d0-9ce4-08003e301f73}"
[Type] = PnpObjectType_DeviceInterface (1)
[1] = {L"System.Devices.DeviceInstanceId" = L"com0com\port\CNCA1"}
如果我根据
修改 Package.appxmanifest 文件
https://docs.microsoft.com/en-us/uwp/schemas/appxpackage/appxmanifestschema/element-devicecapability
<Capabilities>
<DeviceCapability Name="serialcommunication">
<Device Id="any">
<Function Type="name:serialPort" />
</Device>
<!-- added below -->
<DeviceCapability Name="86e0d1e0-8089-11d0-9ce4-08003e301f73"/>
</DeviceCapability>
</Capabilities>
唉
return Concurrency::create_task(SerialDevice::FromIdAsync(device->Id), childToken)
.then([this](SerialDevice ^serial_device)
始终将 null 传递给任何选定 com0com 端口的 lambda 函数 null。
我是不是做错了,或者在 UWP 约束下是不可能的。
Am I doing this incorrectly or is it not possible within the UWP constraints.
很遗憾,FromIdAsync()
method. According to this document 似乎不支持您的情况:
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.
com0com
你这里说的好像是虚拟串口驱动,不是USB连接的,可能不支持
我的 Win32 应用程序通常通过 USB 接口与串行设备通信。多年来,出于诊断和开发目的,我一直使用创建串行环回接口的 Com0Com 实用程序。我现在正在编写我的应用程序的 UWP(非商店)版本。
Com0Com端口在调用时可见
// Construct AQS String for all serial devices on system
Platform::String ^serialDevices_aqs = Windows::Devices::SerialCommunication::SerialDevice::GetDeviceSelector();
// Identify all paired devices satisfying query
return Windows::Devices::Enumeration::DeviceInformation::FindAllAsync(serialDevices_aqs);
添加查看从我获取的串行设备列表中获取的 com0com 端口的 device_ID 值
[Id] = L"\\?\com0com#port#CNCA1#{86e0d1e0-8089-11d0-9ce4-08003e301f73}"
[Type] = PnpObjectType_DeviceInterface (1)
[1] = {L"System.Devices.DeviceInstanceId" = L"com0com\port\CNCA1"}
如果我根据
修改 Package.appxmanifest 文件https://docs.microsoft.com/en-us/uwp/schemas/appxpackage/appxmanifestschema/element-devicecapability
<Capabilities>
<DeviceCapability Name="serialcommunication">
<Device Id="any">
<Function Type="name:serialPort" />
</Device>
<!-- added below -->
<DeviceCapability Name="86e0d1e0-8089-11d0-9ce4-08003e301f73"/>
</DeviceCapability>
</Capabilities>
唉
return Concurrency::create_task(SerialDevice::FromIdAsync(device->Id), childToken)
.then([this](SerialDevice ^serial_device)
始终将 null 传递给任何选定 com0com 端口的 lambda 函数 null。
我是不是做错了,或者在 UWP 约束下是不可能的。
Am I doing this incorrectly or is it not possible within the UWP constraints.
很遗憾,FromIdAsync()
method. According to this document 似乎不支持您的情况:
System-internal or on-chassis serial ports may be enumerated by
DeviceInformation.FindAllAsync()
, but cannot be opened bySerialDevice.FromIdAsync()
because they currently are not supported. However, serial ports connected over USB, such as on USB-to-Serial cables are supported.
com0com
你这里说的好像是虚拟串口驱动,不是USB连接的,可能不支持