C#串口通讯实例
本文参考《C#网络通信程序设计》(张晓明 编著) 程序界面如下图: 参数设置界面代码如下: using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using System.IO.Ports; namespace ComDemo { public partial class ComSet : Form { public ComSet() { InitializeComponent(); } private void ComSet_Load( object sender, EventArgs e) { // 串口 string [] ports = SerialPort.GetPortNames(); foreach ( string port in ports) { cmbPort.Items.Add(port); } cmbPort.SelectedIndex = 0 ; // 波特率 cmbBaudRate.Items.Add( " 110 " );