Hello, your example only has public int getListeningEvents() { return SerialPort.LISTENING_EVENT_DATA_AVAILABLE; } A listener returns;Although the description can be multiple listening events, would like to ask how to achieve? Multiple attempts only trigger the first event condition ;I want to listen SerialPort.LISTENING_EVENT_DATA_AVAILABLE and SerialPort.LISTENING_EVENT_PORT_DISCONNECTED;
@Override //This returns the fixed listener, below serialEvent(SerialPortEvent event)Only this event is
//triggered. Other event states are not,Consult the example scheme
public int getListeningEvents() { return SerialPort.LISTENING_EVENT_DATA_AVAILABLE; }
@Override
public void serialEvent(SerialPortEvent event)
{
System.out.println(event.getEventType() != SerialPort.LISTENING_EVENT_DATA_AVAILABLE);
if (event.getEventType() != SerialPort.LISTENING_EVENT_DATA_AVAILABLE) {
return;
}
Hello, your example only has public int getListeningEvents() { return SerialPort.LISTENING_EVENT_DATA_AVAILABLE; } A listener returns;Although the description can be multiple listening events, would like to ask how to achieve? Multiple attempts only trigger the first event condition ;I want to listen SerialPort.LISTENING_EVENT_DATA_AVAILABLE and SerialPort.LISTENING_EVENT_PORT_DISCONNECTED;