本文介绍了Vis Studio 2015 C#某些设备 - 没有Seri​​alPort对象的串行数据。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,

我有一个非常简单的应用程序,它使用下面的典型事件处理程序从Serialport设备读取数据。

I have a very simple application that reads data from a Serialport device using the typical event handler below.

项目编写于:

Windows 10通用C#桌面项目

Windows 10 Universal C# Desktop Project

Vis studio 2015

Vis studio 2015

我的事件处理程序示例 

Example of my event handler 

private void serialPort1_DataReceived(object sender,System.IO.Ports.SerialDataReceivedEventArgs e)

  ;       {

            //清理变量

            if(RxString!="")

            {

                RxString ="" ;;

                partialName ="" ;;

            }

private void serialPort1_DataReceived(object sender, System.IO.Ports.SerialDataReceivedEventArgs e)
        {
            //clean up variables
            if (RxString != "")
            {
                RxString = "";
                partialName = "";
            }

            RxString = serialPort1.ReadExisting();

            RxString = serialPort1.ReadExisting();

            if(serialPort1.ReadLine()。ToString()!="")

            {

                this.Invoke(new EventHandler(DisplayText));
$
            }

            if (serialPort1.ReadLine().ToString() != "")
            {
                this.Invoke(new EventHandler(DisplayText));
            }

        }

        }

这适用于我插入的几乎所有设备。 Arduino所有口味,其他串行设备等...

This Works fine for almost every device I plug into it. Arduino all flavors, other serial device etc...

除串行设备(Adafruit Bluefruit Micro LE连接USB线)。

Except a Serial Device (Adafruit Bluefruit Micro LE Connected on USB Cable ) .

我创建了这个简单的循环并逐步完成..没有数据显示..

I created this simple loop and step through.. No data ever shows..

  string data ="" ;;

 string data = "";

            while(data =="")

            {

            while (data == "")
            {

                data = serialPort1.ReadExisting();

                data = serialPort1.ReadExisting();

                richTextBox1.AppendText(data);

                richTextBox1.AppendText(data);

            }

            }

        }

        }

我可以在终端仿真器中看到输出,例如TeraTerm。但事件永远不会发生? 确定存在串行数据? 我不了解发生了什么事情? 任何帮助非常感谢:)。

I can see the output in a terminal emulator such as TeraTerm. But the Event Never Fires?  For sure serial data is present?  I do not understand what is happening?  Any help greatly appreciated :).

推荐答案


这篇关于Vis Studio 2015 C#某些设备 - 没有Seri​​alPort对象的串行数据。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-02 20:20