diff --git a/src/main/java/com/fazecast/jSerialComm/SerialPort.java b/src/main/java/com/fazecast/jSerialComm/SerialPort.java index 1c5df53..def0f0d 100644 --- a/src/main/java/com/fazecast/jSerialComm/SerialPort.java +++ b/src/main/java/com/fazecast/jSerialComm/SerialPort.java @@ -2,7 +2,7 @@ * SerialPort.java * * Created on: Feb 25, 2012 - * Last Updated on: Jan 01, 2022 + * Last Updated on: Jan 04, 2022 * Author: Will Hedgecock * * Copyright (C) 2012-2022 Fazecast, Inc. @@ -485,6 +485,7 @@ public final class SerialPort static final public int LISTENING_EVENT_FIRMWARE_OVERRUN_ERROR = 0x00400000; static final public int LISTENING_EVENT_SOFTWARE_OVERRUN_ERROR = 0x00800000; static final public int LISTENING_EVENT_PARITY_ERROR = 0x01000000; + static final public int LISTENING_EVENT_PORT_DISCONNECTED = 0x10000000; // Serial Port Parameters private volatile long portHandle = -1; @@ -914,7 +915,7 @@ public final class SerialPort /** * Adds a {@link SerialPortDataListener} to the serial port interface. *

- * Calling this function enables event-based serial port callbacks to be used instead of, or in addition to, direct serial port read/write calls or the {@link java.io.InputStream}/{@link java.io.OutputStream} interface. + * Calling this function enables event-based serial port callbacks to be used instead of direct serial port read/write calls or the {@link java.io.InputStream}/{@link java.io.OutputStream} interface. *

* The parameter passed into this method must be an implementation of either {@link SerialPortDataListener}, {@link SerialPortDataListenerWithExceptions}, * {@link SerialPortPacketListener}, {@link SerialPortMessageListener} or {@link SerialPortMessageListenerWithExceptions}. diff --git a/src/main/java/com/fazecast/jSerialComm/SerialPortDataListener.java b/src/main/java/com/fazecast/jSerialComm/SerialPortDataListener.java index 8c75766..1764be3 100644 --- a/src/main/java/com/fazecast/jSerialComm/SerialPortDataListener.java +++ b/src/main/java/com/fazecast/jSerialComm/SerialPortDataListener.java @@ -2,10 +2,10 @@ * SerialPortDataListener.java * * Created on: Feb 25, 2015 - * Last Updated on: Dec 17, 2021 + * Last Updated on: Jan 04, 2022 * Author: Will Hedgecock * - * Copyright (C) 2012-2021 Fazecast, Inc. + * Copyright (C) 2012-2022 Fazecast, Inc. * * This file is part of jSerialComm. * @@ -44,6 +44,7 @@ public interface SerialPortDataListener extends EventListener *      {@link SerialPort#LISTENING_EVENT_DATA_AVAILABLE}
*      {@link SerialPort#LISTENING_EVENT_DATA_RECEIVED}
*      {@link SerialPort#LISTENING_EVENT_DATA_WRITTEN}
+ *      {@link SerialPort#LISTENING_EVENT_PORT_DISCONNECTED}
*      {@link SerialPort#LISTENING_EVENT_BREAK_INTERRUPT}
*      {@link SerialPort#LISTENING_EVENT_CARRIER_DETECT}
*      {@link SerialPort#LISTENING_EVENT_CTS}
@@ -58,11 +59,17 @@ public interface SerialPortDataListener extends EventListener *

* Note that event-based write callbacks are only supported on Windows operating systems. As such, the {@link SerialPort#LISTENING_EVENT_DATA_WRITTEN} * event will never be called on a non-Windows system. + *

+ * It is recommended to only use the {@link SerialPort#LISTENING_EVENT_DATA_AVAILABLE}, {@link SerialPort#LISTENING_EVENT_DATA_RECEIVED}, + * {@link SerialPort#LISTENING_EVENT_DATA_WRITTEN}, and/or {@link SerialPort#LISTENING_EVENT_PORT_DISCONNECTED} listening events in production or cross-platform code + * since underlying differences and lack of support for the control line status and error events among the various operating systems and device drivers make it + * unlikely that code listening for these events will behave similarly across different serial devices or OS's, if it works at all. * * @return The event constants that should trigger the {@link #serialEvent(SerialPortEvent)} callback. * @see SerialPort#LISTENING_EVENT_DATA_AVAILABLE * @see SerialPort#LISTENING_EVENT_DATA_RECEIVED * @see SerialPort#LISTENING_EVENT_DATA_WRITTEN + * @see SerialPort#LISTENING_EVENT_PORT_DISCONNECTED * @see SerialPort#LISTENING_EVENT_BREAK_INTERRUPT * @see SerialPort#LISTENING_EVENT_CARRIER_DETECT * @see SerialPort#LISTENING_EVENT_CTS diff --git a/src/main/java/com/fazecast/jSerialComm/SerialPortEvent.java b/src/main/java/com/fazecast/jSerialComm/SerialPortEvent.java index 9142a51..91a4ac0 100644 --- a/src/main/java/com/fazecast/jSerialComm/SerialPortEvent.java +++ b/src/main/java/com/fazecast/jSerialComm/SerialPortEvent.java @@ -2,10 +2,10 @@ * SerialPortEvent.java * * Created on: Feb 25, 2015 - * Last Updated on: Dec 17, 2021 + * Last Updated on: Jan 04, 2022 * Author: Will Hedgecock * - * Copyright (C) 2012-2021 Fazecast, Inc. + * Copyright (C) 2012-2022 Fazecast, Inc. * * This file is part of jSerialComm. * @@ -50,6 +50,7 @@ public class SerialPortEvent extends EventObject *      {@link SerialPort#LISTENING_EVENT_DATA_AVAILABLE}
*      {@link SerialPort#LISTENING_EVENT_DATA_RECEIVED}
*      {@link SerialPort#LISTENING_EVENT_DATA_WRITTEN}
+ *      {@link SerialPort#LISTENING_EVENT_PORT_DISCONNECTED}
*      {@link SerialPort#LISTENING_EVENT_BREAK_INTERRUPT}
*      {@link SerialPort#LISTENING_EVENT_CARRIER_DETECT}
*      {@link SerialPort#LISTENING_EVENT_CTS}
@@ -62,12 +63,16 @@ public class SerialPortEvent extends EventObject *

* Note that event-based write callbacks are only supported on Windows operating systems. As such, the {@link SerialPort#LISTENING_EVENT_DATA_WRITTEN} * event will never be called on a non-Windows system. + *

+ * Also, most control line status and error events from {@link SerialPort#LISTENING_EVENT_BREAK_INTERRUPT} to {@link SerialPort#LISTENING_EVENT_PARITY_ERROR} + * are unlikely to function the same across different operating systems or serial devices on the same operating system, if they work properly at all. * * @param comPort The {@link SerialPort} about which this object is being created. * @param serialEventType The type of serial port event that this object describes. * @see SerialPort#LISTENING_EVENT_DATA_AVAILABLE * @see SerialPort#LISTENING_EVENT_DATA_RECEIVED * @see SerialPort#LISTENING_EVENT_DATA_WRITTEN + * @see SerialPort#LISTENING_EVENT_PORT_DISCONNECTED * @see SerialPort#LISTENING_EVENT_BREAK_INTERRUPT * @see SerialPort#LISTENING_EVENT_CARRIER_DETECT * @see SerialPort#LISTENING_EVENT_CTS @@ -93,6 +98,7 @@ public class SerialPortEvent extends EventObject *      {@link SerialPort#LISTENING_EVENT_DATA_AVAILABLE}
*      {@link SerialPort#LISTENING_EVENT_DATA_RECEIVED}
*      {@link SerialPort#LISTENING_EVENT_DATA_WRITTEN}
+ *      {@link SerialPort#LISTENING_EVENT_PORT_DISCONNECTED}
*      {@link SerialPort#LISTENING_EVENT_BREAK_INTERRUPT}
*      {@link SerialPort#LISTENING_EVENT_CARRIER_DETECT}
*      {@link SerialPort#LISTENING_EVENT_CTS}
@@ -105,6 +111,9 @@ public class SerialPortEvent extends EventObject *

* Note that event-based write callbacks are only supported on Windows operating systems. As such, the {@link SerialPort#LISTENING_EVENT_DATA_WRITTEN} * event will never be called on a non-Windows system. + *

+ * Also, most control line status and error events from {@link SerialPort#LISTENING_EVENT_BREAK_INTERRUPT} to {@link SerialPort#LISTENING_EVENT_PARITY_ERROR} + * are unlikely to function the same across different operating systems or serial devices on the same operating system, if they work properly at all. * * @param comPort The {@link SerialPort} about which this object is being created. * @param serialEventType The type of serial port event that this object describes. @@ -112,6 +121,7 @@ public class SerialPortEvent extends EventObject * @see SerialPort#LISTENING_EVENT_DATA_AVAILABLE * @see SerialPort#LISTENING_EVENT_DATA_RECEIVED * @see SerialPort#LISTENING_EVENT_DATA_WRITTEN + * @see SerialPort#LISTENING_EVENT_PORT_DISCONNECTED * @see SerialPort#LISTENING_EVENT_BREAK_INTERRUPT * @see SerialPort#LISTENING_EVENT_CARRIER_DETECT * @see SerialPort#LISTENING_EVENT_CTS @@ -144,6 +154,7 @@ public class SerialPortEvent extends EventObject *      {@link SerialPort#LISTENING_EVENT_DATA_AVAILABLE}
*      {@link SerialPort#LISTENING_EVENT_DATA_RECEIVED}
*      {@link SerialPort#LISTENING_EVENT_DATA_WRITTEN}
+ *      {@link SerialPort#LISTENING_EVENT_PORT_DISCONNECTED}
*      {@link SerialPort#LISTENING_EVENT_BREAK_INTERRUPT}
*      {@link SerialPort#LISTENING_EVENT_CARRIER_DETECT}
*      {@link SerialPort#LISTENING_EVENT_CTS}
@@ -156,11 +167,15 @@ public class SerialPortEvent extends EventObject *

* Note that event-based write callbacks are only supported on Windows operating systems. As such, the {@link SerialPort#LISTENING_EVENT_DATA_WRITTEN} * event will never be called on a non-Windows system. + *

+ * Also, most control line status and error events from {@link SerialPort#LISTENING_EVENT_BREAK_INTERRUPT} to {@link SerialPort#LISTENING_EVENT_PARITY_ERROR} + * are unlikely to function the same across different operating systems or serial devices on the same operating system, if they work properly at all. * * @return The serial port event that this object describes. * @see SerialPort#LISTENING_EVENT_DATA_AVAILABLE * @see SerialPort#LISTENING_EVENT_DATA_RECEIVED * @see SerialPort#LISTENING_EVENT_DATA_WRITTEN + * @see SerialPort#LISTENING_EVENT_PORT_DISCONNECTED * @see SerialPort#LISTENING_EVENT_BREAK_INTERRUPT * @see SerialPort#LISTENING_EVENT_CARRIER_DETECT * @see SerialPort#LISTENING_EVENT_CTS