与USB打印机串行端口通信

时间:2020-02-20 14:09:13

标签: java linux serial-port

我正在尝试通过串行端口与Edito(Seiko)KSM347打印机通信。我已经通过echo "test" > /dev/usb/lp1或Java代码成功打印了数据:

FileOutputStream fs = new FileOutputStream("/dev/usb/lp1");
PrintStream ps = new PrintStream(fs);
ps.write(cmd); // cmd is bytes with corresponding commands
ps.flush();

它也正常工作。但是我需要发送数据并获得响应。在其他项目中,我一直在使用RXTX库,该库可以很好地与华为MU609调制解调器配合使用。现在,该库看不到这些/dev/usb/端口。

CommPortIdentifier portId = null;
Enumeration portEnum = CommPortIdentifier.getPortIdentifiers();
// this list contains only /dev/ttyS0 and /dev/ttyUSB0 devices.

如何强制RXTX使用这些端口?甚至设置-Dgnu.io.rxtx.SerialPorts也不起作用。请帮忙:)

0 个答案:

没有答案