可供选择的串口 [英] available serial port for selection

查看:101
本文介绍了可供选择的串口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

hi
我想使用串口,​​并有2个组合框作为SerialPort PortName(组合框1)和SerialPort BaudRate(组合框2)。我想使用SerialPort PortName作为可用端口并在组合框上显示它们,而不是其他可能不可用的端口

我该怎么做?

hi i want to use serial port, and have 2 combo boxes as SerialPort PortName(combo box1) and SerialPort BaudRate(combo box2). i want to use SerialPort PortName for available ports and display just them on combo box, not other ports that maybe not available
what shall i do for this?

推荐答案

你可以找到哪些端口(可能)可以使用 SerialPort.GetNames [ ^ ] - 但是...这会查询注册表,因此它可能不准确,因为它可以返回不再存在的端口。



并且没有自动系统来检测可用端口 - 如果某个端口正在被另一个程序使用它将不会可用,但AFAIK检查的唯一方法是尝试打开它并且捕获异常。
You can find out what ports are (probably) availble with SerialPort.GetNames[^] - but...this queries the registry, so it may be inaccurate in that it can return ports that aren't there any more.

And there is no "automatic" system fort detecting "available" ports - if a port is in use by another program it will not be "available" but AFAIK the only way to check is to try opening it and catching the exception.


这篇关于可供选择的串口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆