无法使用 Raspberry Pi 3 在 Windows IoT 上打开 UART 端口 [英] Unable to open UART port on Windows IoT with Raspberry Pi 3

查看:28
本文介绍了无法使用 Raspberry Pi 3 在 Windows IoT 上打开 UART 端口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 Raspberry Pi 3 上运行的 Windows IoT Core 10 上,在 C# 中打开 SerialDevice 后,串口中的值为 null.

I have null in the serial port after I open the SerialDevice in C# on Windows IoT Core 10 running on Raspberry Pi 3.

代码如下:

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}" 字符串

list.Count 等于 1

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

Here are two records from /api/devicemanager/devices GET request related to UART:

{
  "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 短接,但没有将其短接,它不起作用...

I tried both to short circuit Rx and Tx and to not shortly circuit it, it doesn't works...

更新

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

If I split the given ID, I have Invalid data exception.

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; }

输出:

抛出异常:mscorlib.ni.dll 中的System.Exception"
数据无效.(来自 HRESULT 的异常:0x8007000D)
数据无效.(来自 HRESULT 的异常:0x8007000D)
没有设备

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 所说,解决方案在这里:SerialDevice.FromIdAsync() 产生一个空串口

As 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 文件中的 标签中.

in the <Capabilities> tag in Package.appxmanifest file.

这篇关于无法使用 Raspberry Pi 3 在 Windows IoT 上打开 UART 端口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆