无法使用 Raspberry Pi 3 在 Windows IoT 上打开 UART 端口

Unable to open UART port on Windows IoT with Raspberry Pi 3

在 Windows IoT Core 10 运行 在 Raspberry Pi 3.

上用 C# 打开 SerialDevice 后,串口为空

代码如下:

string aqs = SerialDevice.GetDeviceSelector();
DeviceInformationCollection devices = await DeviceInformation.FindAllAsync(aqs);
List<DeviceInformation> list = devices.ToList();
DeviceInformation di = list.First();
serialPort = await SerialDevice.FromIdAsync(di.Id);

serialPortnull

di.Id 等于:Id "\\?\ACPI#BCM2836#0#{86e0d1e0-8089-11d0-9ce4-08003e301f73}" string

list.Count等于1

这是来自 /api/devicemanager/devices GETUART 相关的请求的两条记录:

{
  "Class": "Ports",
  "Description": "BCM283x Mini UART Serial Device",
  "ID": "ACPI\BCM2836\0",
  "Manufacturer": "Microsoft",
  "ParentID": "ACPI_HAL\PNP0C08\0",
  "ProblemCode": 0,
  "StatusCode": 25182218
},
{
  "Class": "System",
  "Description": "ARM PL011 UART Device Driver",
  "ID": "ACPI\BCM2837\4",
  "Manufacturer": "Microsoft",
  "ParentID": "ACPI_HAL\PNP0C08\0",
  "ProblemCode": 0,
  "StatusCode": 25165834
},

我试过将 Rx 和 Tx 短接和不短接它,它不起作用...

更新

如果我拆分给定的 ID,我有 Invalid data 个异常。

string aqs = SerialDevice.GetDeviceSelector();
DeviceInformationCollection devices = await DeviceInformation.FindAllAsync(aqs);
List<DeviceInformation> list = devices.ToList();
DeviceInformation di = list.First();

string id = "{86e0d1e0-8089-11d0-9ce4-08003e301f73}";
try { serialPort = await SerialDevice.FromIdAsync(id); } catch(Exception e) { Debug.WriteLine(e.Message); }
id = "\\?\ACPI#BCM2836#0#";
try { serialPort = await SerialDevice.FromIdAsync(id); } catch(Exception e) { Debug.WriteLine(e.Message); }
id = di.Id;
try { serialPort = await SerialDevice.FromIdAsync(id); } catch(Exception e) { Debug.WriteLine(e.Message); }
if (serialPort == null) { Debug.WriteLine("No device"); return; }

输出:

Exception thrown: 'System.Exception' in mscorlib.ni.dll
The data is invalid. (Exception from HRESULT: 0x8007000D)
The data is invalid. (Exception from HRESULT: 0x8007000D)
No device

作为Grim said, the solution is here: SerialDevice.FromIdAsync() yields a null serial port

需要补充:

<DeviceCapability Name="serialcommunication">
  <Device Id="any">
    <Function Type="name:serialPort" />
  </Device>
</DeviceCapability>

Package.appxmanifest 文件的 <Capabilities> 标签中。