Java串行编程
所以我试图读取连接到com端口的串行设备的数据。 现在我知道了阅读部分,但我想知道的是,我如何识别连接的设备是我的设备,还是鼠标或键盘之类的其他设备。 作为参考,我使用jssc
非常感谢
下面这一部分使用Jssc从我的rfid阅读器读取rfid标签
public static void main(String[] args) {
SerialPort serialPort = new SerialPort("COM1");
try {
serialPort.openPort();//Open serial port
byte[] buffer = serialPort.readBytes(12);
serialPort.closePort();//Close serial port
}
catch (SerialPortException ex) {
System.out.println(ex);
}
}
# 1 楼答案
不确定我是否正确理解了你的意图,但你可以使用AT命令获取设备信息,比如
发送命令后,请务必等待,然后才能尝试从设备读取答案