C#获取有效的串口
来源:互联网 发布:贵州大数据交易所总裁 编辑:程序博客网 时间:2024/05/17 06:58
如题:
直接上代码
public Form1() { InitializeComponent(); this.Load += Form1_Load; } void Form1_Load(object sender, EventArgs e) { string[] ArryPort = SerialPort.GetPortNames(); comboBox1.Items.Clear(); for (int i = 0; i < ArryPort.Length; i++) { comboBox1.Items.Add(ArryPort[i]); } comboBox1.SelectedIndex = 1; }
问题:
1、上面的代码是启动的时候扫描出来的
2、当串口不存在时需要被扫描出来
3、串口助手需要定时检测
4、待续。。。
阅读全文