首页 > 解决方案 > 如何在 Windows 10 中为 Java 中的方法 SerialPort.getCommPort() 获取串行端口的名称

问题描述

SerialPort sp = SerialPort.getCommPort(); //<-- 这里,如何知道参数是什么

sp.setComPortParameters(9600, 8, 1, 0);

sp.setComPortTimeouts(SerialPort.TIMEOUT_WRITE_BLOCKING, 0, 0);

标签: javaarduinoserial-portarduino-unoarduino-ide

解决方案


您应该通过以下方式获取可用端口SerialPort[] serialPorts = SerialPort.getCommPorts();

然后,将其中一个 serialPort 传递给参数。


推荐阅读