无法在Raspberry Pi 2上打开Arduino的串口 [英] Can't open serial port to Arduino on Raspberry Pi 2
问题描述
我为IoT(5/12版本)安装了Windows,并尝试使用Arduino设备打开串行连接。它使用Raspbian很好地连接,但是我遇到了Windows的问题。
我在功能中添加了以下内容:
< DeviceCapability Name =" serialcommunication">
< Device Id =" any">
< Function Type =" name:serialPort" />
< / Device>
< / DeviceCapability>
以下代码用于尝试打开端口:
Log(" GetDeviceSelector ..");
var aqsFilter = SerialDevice.GetDeviceSelector();
Log("Getting dev infos ..");
var deviceInfos = await DeviceInformation.FindAllAsync(aqsFilter);
Log(" Found" + deviceInfos.Count);
if(deviceInfos.Count == 0)
{
this.Log(" No serial port found");
返回null;
}
日志("获取第一个设备信息...");
var firstDeviceInfo = deviceInfos.First();
Log("Trying device"+ firstDeviceInfo);
Log("Opening serial port ..");
返回等待SerialDevice.FromIdAsync(firstDeviceInfo.Id);
从SerialDevice.FromIdAsync返回的串口为空,而DeviceInfo正确填写并且看起来不错。有什么我想念的吗?
我相信它是SerialDevice类中的一个错误。我有同样的问题,但是来自通用Windows程序。
这是我开始的主题:
https://social.msdn.microsoft .com /论坛/ windowsapps / en-US / 0c638b8e-482d-462a-97e6-4d8bc86d8767 / uwp-windows-10-apps-windowsdevicesserialcommunicationserialdevice-class-not-working?forum = wpdevelop
I installed Windows for IoT (5/12 build) and am trying to open a serial connection with an Arduino device. It connects fine using Raspbian, but I'm running into problems with Windows.
I added the following to the capabilities:
<DeviceCapability Name="serialcommunication"> <Device Id="any"> <Function Type="name:serialPort" /> </Device> </DeviceCapability>
The following code is used to try to open the port:
Log("GetDeviceSelector.."); var aqsFilter = SerialDevice.GetDeviceSelector(); Log("Getting dev infos.."); var deviceInfos = await DeviceInformation.FindAllAsync(aqsFilter); Log("Found " + deviceInfos.Count); if(deviceInfos.Count == 0) { this.Log("No serial port found"); return null; } Log("Get first deviceinfo.."); var firstDeviceInfo = deviceInfos.First(); Log("Trying device " + firstDeviceInfo); Log("Opening serial port.."); return await SerialDevice.FromIdAsync(firstDeviceInfo.Id);
The serial port returned from SerialDevice.FromIdAsync is null while the DeviceInfo is filled in properly and looks good. Is there something I'm missing?
I believe its a bug in the SerialDevice Class. I have the same issue but from a Universal Windows Program.
Here's the thread that I started:
https://social.msdn.microsoft.com/Forums/windowsapps/en-US/0c638b8e-482d-462a-97e6-4d8bc86d8767/uwp-windows-10-apps-windowsdevicesserialcommunicationserialdevice-class-not-working?forum=wpdevelop
这篇关于无法在Raspberry Pi 2上打开Arduino的串口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!