Raspberry Pi 3上的USB串口设备状态大多是未知的? [英] USB Serial Device Status is mostly UNKNOWN on Raspberry Pi 3?

查看:100
本文介绍了Raspberry Pi 3上的USB串口设备状态大多是未知的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个USB串口设备(它从连接的探头读取SPO2和Pulse)它可以在PC上正常工作但在树莓Pi 3上它可以在某些时候工作!我还没弄清楚为什么。在PowerShell中运行命令时 


Get-PnpDevice  - 类"端口"


它说大多数时候USB串口设备都是未知的,有时候还可以!系统工作我还没有找到原因......就像许多轮胎中的一次一样!


我断开了设备并将示例表格与Windows开发中心相关联 - Raspberry Pi 2& 3针映射




public async void Serial()


{


    string aqs = SerialDevice.GetDeviceSelector(" UART0");                   / *查找串行设备的选择器字符串   * /


    var dis = await DeviceInformation.FindAllAsync(aqs);                    / *使用我们的选择器字符串查找串行设备  * /


    SerialDevice SerialPort = await SerialDevice.FromIdAsync(dis [0] .Id);    / *使用我们选择的设备创建一个串行设备* /




    / *配置串口设置* /


    SerialPort.WriteTimeout = TimeSpan.FromMilliseconds(1000);


    SerialPort.ReadTimeout = TimeSpan.FromMilliseconds(1000);


    SerialPort.BaudRate = 9600;


    SerialPort.Parity = SerialParity.None;


    SerialPort.StopBits = SerialStopBitCount.One;


    SerialPort.DataBits = 8;




    / *通过串口写出一个字符串* /


    string txBuffer =" Hello Serial";


    DataWriter dataWriter = new DataWriter();


    dataWriter.WriteString(txBuffer);


    uint bytesWritten = await SerialPort.OutputStream.WriteAsync(dataWriter.DetachBuffer());




    / *从串口读取数据* /


    const uint maxReadLength = 1024;


    DataReader dataReader = new DataReader(SerialPort.InputStream);


    uint bytesToRead = await dataReader.LoadAsync(maxReadLength);  // doest获取数据


    string rxBuffer = dataReader.ReadString(bytesToRead);


}


我为每条指令的serialPort添加了Package.appxmanifest的功能。但似乎代码从未读过数据。有人可以告诉我可能出现什么问题吗?


非常感谢


abahrami

解决方案

您好Abahrami,


您是否在此论坛上搜索过在RPi上发布了有关USB序列的其他人? 例如

https://social.msdn.microsoft.com/Forums/en-US/d44a04a5-69fc-4d0e-b746-620724acdcda/windows-10-iot-rpi3- usb-serial-uart-problems?forum = WindowsIoT
似乎与您的体验非常相似。


此致


IoTGirl


I have a USB serial device (it reads SPO2 and Pulse from the attached probe) it works fine on a PC but on raspberry Pi 3 it works some of the time! which I have not figure out Why. In the PowerShell when I ran the command 

Get-PnpDevice  -Class "Ports"

It Says that the USB Serial device is Unknown most of the time and sometimes it is OK! And system works I haven’t find why… that is like once in many many tires!

I disconnected the device and tied the example form the Windows Dev Center - Raspberry Pi 2 & 3 Pin Mappings


public async void Serial()

{

    string aqs = SerialDevice.GetDeviceSelector("UART0");                   /* Find the selector string for the serial device   */

    var dis = await DeviceInformation.FindAllAsync(aqs);                    /* Find the serial device with our selector string  */

    SerialDevice SerialPort = await SerialDevice.FromIdAsync(dis[0].Id);    /* Create an serial device with our selected device */


    /* Configure serial settings */

    SerialPort.WriteTimeout = TimeSpan.FromMilliseconds(1000);

    SerialPort.ReadTimeout = TimeSpan.FromMilliseconds(1000);

    SerialPort.BaudRate = 9600;

    SerialPort.Parity = SerialParity.None;

    SerialPort.StopBits = SerialStopBitCount.One;

    SerialPort.DataBits = 8;


    /* Write a string out over serial */

    string txBuffer = "Hello Serial";

    DataWriter dataWriter = new DataWriter();

    dataWriter.WriteString(txBuffer);

    uint bytesWritten = await SerialPort.OutputStream.WriteAsync(dataWriter.DetachBuffer());


    /* Read data in from the serial port */

    const uint maxReadLength = 1024;

    DataReader dataReader = new DataReader(SerialPort.InputStream);

    uint bytesToRead = await dataReader.LoadAsync(maxReadLength);  // doest get data

    string rxBuffer = dataReader.ReadString(bytesToRead);

}

I added the capability to the Package.appxmanifest for serialPort per instruction. But it seems the code never read the data. Can someone tell me what might wrong?

Many thanks

abahrami

解决方案

Hi Abahrami,

Have you searched this forum for others that have posted regarding USB serial on RPi?  For example https://social.msdn.microsoft.com/Forums/en-US/d44a04a5-69fc-4d0e-b746-620724acdcda/windows-10-iot-rpi3-usb-serial-uart-problems?forum=WindowsIoT seems very similar to your experience.

Sincerely,

IoTGirl


这篇关于Raspberry Pi 3上的USB串口设备状态大多是未知的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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