如何通过com端口接收数据? [英] how to recieve data via com port?
本文介绍了如何通过com端口接收数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何通过com端口接收数据
how to recieve data via com port
推荐答案
要访问comport,您需要具有名称空间
使用System.IO.Ports;
然后在按钮单击事件中写这个
{
然后需要像这样为串行端口创建对象
In order to access comport you need to have namespace
using System.IO.Ports;
then in button click event write this
{
then need to create an object for serial port like this
SerialPort obj = new SerialPort("COM1");//But be shore that the bardrate matches between hardware and computer system
obj.Open();
string a = obj.ReadExisting();
obj.Close();
MessageBox.Show(a);
}
希望对您有帮助
Hope this may help you
这篇关于如何通过com端口接收数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文