我的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端口的com0com值
[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文件
<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)对于所选的com0com端口,总是将null传递给lambda函数null。
我是做错了,还是不可能在UWP的约束下。
发布于 2018-01-17 06:11:47
我是做错了,还是不可能在UWP的约束下。
不幸的是,FromIdAsync()方法似乎不支持您的情况。根据本文件
DeviceInformation.FindAllAsync()可以枚举系统内部或机箱上的串行端口,但SerialDevice.FromIdAsync()不能打开它们,因为它们目前不受支持。但是,通过USB连接的串行端口(如USB到串行电缆上的)是受支持的.
您在这里提到的com0com似乎是虚拟串口驱动程序,它不是通过USB连接的,可能不受支持。
https://stackoverflow.com/questions/48254104
复制相似问题