我有视窗IoT核心10 17744运行在覆盆子Pi 3。
我尝试使用以下代码从UWP应用程序初始化COM端口:
string aqs = SerialDevice.GetDeviceSelector();
DeviceInformationCollection devices = await DeviceInformation.FindAllAsync(aqs);
List<DeviceInformation> list = devices.ToList();
DeviceInformation di = list.First();
_serial_port = await SerialDevice.FromIdAsync(di.Id);我有di.Id -> \\?\ACPI#BCM2836#0#{86e0d1e0-8089-11d0-9ce4-08003e301f73}
di变量的完全表示如下:
- di {Windows.Devices.Enumeration.DeviceInformation} Windows.Devices.Enumeration.DeviceInformation
EnclosureLocation null Windows.Devices.Enumeration.EnclosureLocation
Id "\\\\?\\ACPI#BCM2836#0#{86e0d1e0-8089-11d0-9ce4-08003e301f73}" string
IsDefault false bool
IsEnabled true bool
Kind DeviceInterface Windows.Devices.Enumeration.DeviceInformationKind
Name "MINWINPC" string
- Pairing {Windows.Devices.Enumeration.DeviceInformationPairing} Windows.Devices.Enumeration.DeviceInformationPairing
CanPair false bool
+ Custom {Windows.Devices.Enumeration.DeviceInformationCustomPairing} Windows.Devices.Enumeration.DeviceInformationCustomPairing
IsPaired false bool
ProtectionLevel None Windows.Devices.Enumeration.DevicePairingProtectionLevel
Native View To inspect the native object, enable native code debugging.
+ Properties {System.__ComObject} System.Collections.Generic.IReadOnlyDictionary<string, object> {System.__ComObject}
Native View To inspect the native object, enable native code debugging. 但是在await操作之后,_serial_port中的值为null。
更新
即使我将Raspberry接口连接到工作节点,它也是null:
第8针作为TX成对的RX线。
第10引脚为RX成对TX线。
更新
我在清单中有DeviceCapability:
<DeviceCapability Name="serialcommunication">
<Device Id="any">
<Function Type="name:serialPort" />
</Device>
</DeviceCapability>发布于 2019-03-14 00:59:10
您需要在Package.appxmanifest中添加串行设备功能。
<DeviceCapability Name="serialcommunication">
<Device Id="any">
<Function Type="name:serialPort" />
</Device>
</DeviceCapability>即使我将Raspberry UART接口连接到工作节点:作为TX的第8引脚到成对的RX线,它也是空的。第10引脚为RX成对TX线。
这并不是SerialDevice.FromIdAsync()成功的必要条件。即使没有连接这些引脚,如果代码和设置正确,SerialDevice.FromIdAsync()也可以获得有效的设备。您可以参考串行UART样本。
https://stackoverflow.com/questions/55142683
复制相似问题