Fazecast / jSerialComm

Platform-independent serial port access for Java
GNU Lesser General Public License v3.0
1.35k stars 287 forks source link

What is the recommended replacement for com.fazecast.jserialcomm.serialporteventlistener #491

Closed CryptoClinck closed 1 year ago

CryptoClinck commented 1 year ago

Hello,

I had code like this working with previous version of the library:

public boolean open(final String portName) { SerialPort[] ports = SerialPort.getCommPorts(); final List<SerialPort> matchingPorts = Stream.of(ports).filter(port -> port.getSystemPortName().equals(portName)).collect(Collectors.toList()); if (matchingPorts.isEmpty()) { return false; } serialPort = matchingPorts.get(0); serialPort.setComPortParameters(baudRate, dataBits, stopBits, parity); serialPort.setComPortTimeouts(SerialPort.TIMEOUT_READ_BLOCKING, 0, 0); if (serialPort.openPort()) { input = new BufferedReader(new InputStreamReader(serialPort.getInputStream())); output = serialPort.getOutputStream(); serialPort.addDataListener(this); isOpen = true; } return isOpen; }

The method addDataListener doesn't exist anymore.

What can I use instead ?

Thanks

NorbertSandor commented 1 year ago

The method exists in 2.9.3:

image

Ps.: please format your code snippet to make it readable

CryptoClinck commented 1 year ago

Problem solved.

It was not addDataListener the cause of the error but SerialPortEventListener.

CryptoClinck commented 1 year ago

The method exists in 2.9.3:

image

Ps.: please format your code snippet to make it readable

Thanks for your response. I used the button "add code" to add the code but format is not working :-(