我在我的 com 端口连接了一个设备,我正在尝试获取它的值,但我被困在第一步。
我无法获取现有的 com 端口。在下面的代码中,枚举似乎是空的,因为程序根本没有进入 while 循环。谁能帮忙
public class connectnow implements Runnable, SerialPortEventListener {
static CommPortIdentifier portId;
static Enumeration portList;
InputStream inputStream;
SerialPort serialPort;
Thread readThread;
byte[] readBuffer;
public static void main(String[] args) {
portList = CommPortIdentifier.getPortIdentifiers();
System.out.println("portList... " + portList);
while (portList.hasMoreElements()) {
System.out.println("yes");
}
}