本文介绍了无法在Raspberry Pi 2上打开Arduino的串口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我为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正确填写并且看起来不错。有什么我想念的吗?
解决方案
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?
解决方案
这篇关于无法在Raspberry Pi 2上打开Arduino的串口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!