From 987f58b972806f92d511c6f1174f8f3cbe089ee7 Mon Sep 17 00:00:00 2001 From: jskubick Date: Wed, 21 Feb 2024 20:05:37 -0500 Subject: [PATCH] Updated example code in SerialPort.isOpen()'s Javadoc to mention that there can be ONLY ONE DataListener --- src/main/java/com/fazecast/jSerialComm/SerialPort.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/main/java/com/fazecast/jSerialComm/SerialPort.java b/src/main/java/com/fazecast/jSerialComm/SerialPort.java index e029446c..b9fda6fe 100644 --- a/src/main/java/com/fazecast/jSerialComm/SerialPort.java +++ b/src/main/java/com/fazecast/jSerialComm/SerialPort.java @@ -666,9 +666,16 @@ public final boolean closePort() * // (atOverride annotations omitted to avoid confusing Javadoc generator, but necessary in actual use) * public int getListeningEvents() { * return SerialPort.LISTENING_EVENT_PORT_DISCONNECTED; + * // or, if you want to listen for multiple events (see warning below): + * // return SerialPort.LISTENING_EVENT_PORT_DISCONNECTED | SerialPort.LISTENING_EVENT_DATA_RECEIVED * } * public void serialEvent(SerialPortEvent serialPortEvent) { * port.closePort(); + * // or, if you're listening for two or more events: + * // if (serialPortEvent.getEventType() == SerialPort.LISTENING_EVENT_PORT_DISCONNECTED) + * // port.closePort(); + * // else if (serialPortEvent.getEventType() == SerialPort.LISTENING_EVENT_DATA_RECEIVED) + * // ... you get the idea * } * }); * @@ -682,6 +689,9 @@ public final boolean closePort() * not work again until the SerialPort object's close() and open() methods have both been called to * re-establish the connection. * + *

WARNING! There can be **only one** DataListener. To Listen for multiple SerialPortEvents, + * OR (|) them together in getListeningEvents(), and check to see which event fired in serialEvent(). + * * @return Whether the port is opened. */ public final boolean isOpen()