My Win32 application normally communicates with a serial device via a USB interface. For diagnostic and development purposes for many years I have made use of the Com0Com utility which creates serial loopback interfaces. I am now writing a UWP(Non-Store) version of my application.
The Com0Com ports are visible when calling
// 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);
Add looking at the device_ID value of the the com0com ports fetched from my fetch of the list of serial devices
[Id] = L"\\\\?\\com0com#port#CNCA1#{86e0d1e0-8089-11d0-9ce4-08003e301f73}"
[Type] = PnpObjectType_DeviceInterface (1)
[1] = {L"System.Devices.DeviceInstanceId" = L"com0com\\port\\CNCA1"}
And if I modify the Package.appxmanifest file per
<Capabilities>
<DeviceCapability Name="serialcommunication">
<Device Id="any">
<Function Type="name:serialPort" />
</Device>
<!-- added below -->
<DeviceCapability Name="86e0d1e0-8089-11d0-9ce4-08003e301f73"/>
</DeviceCapability>
</Capabilities>
alas
return Concurrency::create_task(SerialDevice::FromIdAsync(device->Id), childToken)
.then([this](SerialDevice ^serial_device)
alway passes null to the lambda function null for any of the selected com0com ports.
Am I doing this incorrectly or is it not possible within the UWP constraints.
Am I doing this incorrectly or is it not possible within the UWP constraints.
Unfortunately, it seems like your situation is not supported by 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
you mentioned here seems to be the virtual serial port driver which is not connected over USB and may not be supported.