1

com0com COM13 and COM14

var selector = SerialDevice.GetDeviceSelector("COM14");
var informations = await DeviceInformation.FindAllAsync(selector);

if (informations.Any())
{
    var port = await SerialDevice.FromIdAsync(informations.First().Id);
}

informations.Any() is false

Where is my error?

plexusilnur
  • 61
  • 1
  • 5

2 Answers2

1

I haven't tried it on UWP, but there is a Windows quirk when accessing COM ports of 10 or greater: you need to specify the full symbolic device name from user mode. I.e., prepend a \\.\:

var selector = SerialDevice.GetDeviceSelector(@"\\.\COM14");
Stephen Cleary
  • 437,863
  • 77
  • 675
  • 810
  • Thanks for answer. But now, if I write "COM14" informations.Any() is TRUE. But await SerialDevice.FromIdAsync(informations.First().Id) == NULL. – plexusilnur Jan 24 '17 at 04:03
1

The Microsoft SerialCommuncation docs site describes that System-internal ports are currently not supported: Microsoft Docs about windows.devices.serialcommunication

I don’t understand why not, and they may add this functionality in the future.

A workaround is:

C# Use the standard .NET System.IO.Ports.SerialPort class (except GetPortNames()) everything works in .NET for UWP 6.1.5. As replacement for GetPortNames you can P/Interop to GetCommPorts.

C++/winrt Use the new Windows 10 RS3/4 API call OpenCommPort. See the Windows header files for the function prototype, as this function is currently not documented on MS docs.

Note also ensure that in your .appxmanifest file you app "claims" access to a serial port:

<DeviceCapability Name="serialcommunication">
  <Device Id="any">
    <Function Type="name:serialPort" />
  </Device>
</DeviceCapability>
Victor Derks
  • 360
  • 4
  • 12