java - 如何在 Windows 10 中为 Java 中的方法 SerialPort.getCommPort() 获取串行端口的名称
问题描述
SerialPort sp = SerialPort.getCommPort(); //<-- 这里,如何知道参数是什么
sp.setComPortParameters(9600, 8, 1, 0);
sp.setComPortTimeouts(SerialPort.TIMEOUT_WRITE_BLOCKING, 0, 0);
解决方案
您应该通过以下方式获取可用端口SerialPort[] serialPorts = SerialPort.getCommPorts();
然后,将其中一个 serialPort 传递给参数。
推荐阅读
- mongodb - MongoDB 动态评估字段名称
- java - 如何在不同库中的两个 jar 之间进行选择?
- java - 如何在 DTO 中返回枚举?
- python - Apache Beam 流式传输管道中的侧输入产生错误“NoneType 没有属性 max_timestamp”
- java - 是否可以在 HTTP 标头中动态更改标头数据
- java - 安装失败缺少的共享库
- javascript - js中每秒刷新数据(异步函数)
- python - 在 Django 中,charfield 避免字符重复
- python - 使用 pycharm 文件从 github 克隆
- flutter - 颤振消息未发送