如何在C#中从串行端口读取数据 [英] how to read data from serial port in c#
本文介绍了如何在C#中从串行端口读取数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
您好全部
我在项目中使用了串行端口通信代码,但未读取数据
给我打电话给这个解决方案
我正在使用以下方法从Serialport读取数据
hello All
I am using serialport communication code in my project but it is not reading data
tel me the solution for this
i am using the folloing method for reading data from serialport
private void Read_Click(object sender, EventArgs e)
{
try
{
//clear the text box
textBox.Text = "";
//read serial port and displayed the data in text box
textBox.Text = sp.ReadLine();
}
catch (System.Exception ex)
{
baudRatelLabel.Text = ex.Message;
}
}
推荐答案
您已经打开并设置了SerialPort(不幸的是,上面的代码缺少这一部分)?
MSDN在此处提供了很好的示例:
http://msdn.microsoft.com/de-de/library/system. io.ports.serialport.aspx [ ^ ]
致以最诚挚的问候
Hi,
you''ve already opened and setted up your SerialPort (unfortunately this part of code is missing above)?
MSDN Provides great example here:
http://msdn.microsoft.com/de-de/library/system.io.ports.serialport.aspx[^]
With Best Regards
这篇关于如何在C#中从串行端口读取数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文