2015-11-20 15:10:09
补充:串口要添加对应的空间
//获取com口
using System.IO.Ports;
c#有串口控件
设计界面如下:
重要的几个函数
构造函数
InitializeComponent();
//为串口绑定接收数据事件
this.serialPort1.DataReceived += new SerialDataReceivedEventHandler(DataReceivedHandler);
//初始化下拉串口名称列表框
string[] ports = SerialPort.GetPortNames();
Array.Sort(ports);
dotlist.Add(100);
/*
串口设置
this.serialPort1.PortNum= comboBox1.Text.ToString(); //端口号
this.serialPort1.Parity= 0; //奇偶校验
this.serialPort1.BaudRate= 9600;//串口通信波特率
this.serialPort1.ByteSi