From 37d910d3183bc6db306362f6e818ca795a25ac24 Mon Sep 17 00:00:00 2001 From: lsiepel Date: Sat, 7 Dec 2024 16:44:46 +0100 Subject: [PATCH] Catch ISE (#17854) Signed-off-by: Leo Siepel --- .../dsmr/internal/device/connector/DSMRErrorStatus.java | 4 ++++ .../dsmr/internal/device/connector/DSMRSerialConnector.java | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/bundles/org.openhab.binding.dsmr/src/main/java/org/openhab/binding/dsmr/internal/device/connector/DSMRErrorStatus.java b/bundles/org.openhab.binding.dsmr/src/main/java/org/openhab/binding/dsmr/internal/device/connector/DSMRErrorStatus.java index 3d14c32afaa..a197777038b 100644 --- a/bundles/org.openhab.binding.dsmr/src/main/java/org/openhab/binding/dsmr/internal/device/connector/DSMRErrorStatus.java +++ b/bundles/org.openhab.binding.dsmr/src/main/java/org/openhab/binding/dsmr/internal/device/connector/DSMRErrorStatus.java @@ -44,6 +44,10 @@ public enum DSMRErrorStatus { * Serial port doesn't support the configured settings. */ PORT_NOT_COMPATIBLE(true), + /** + * Serial port time out or illegal state. + */ + PORT_PORT_TIMEOUT(false), /** * Reading data from the serial port failed. */ diff --git a/bundles/org.openhab.binding.dsmr/src/main/java/org/openhab/binding/dsmr/internal/device/connector/DSMRSerialConnector.java b/bundles/org.openhab.binding.dsmr/src/main/java/org/openhab/binding/dsmr/internal/device/connector/DSMRSerialConnector.java index 550325e00ca..5e7dbb014f3 100644 --- a/bundles/org.openhab.binding.dsmr/src/main/java/org/openhab/binding/dsmr/internal/device/connector/DSMRSerialConnector.java +++ b/bundles/org.openhab.binding.dsmr/src/main/java/org/openhab/binding/dsmr/internal/device/connector/DSMRSerialConnector.java @@ -172,6 +172,10 @@ public class DSMRSerialConnector extends DSMRBaseConnector implements SerialPort logger.warn("Possible bug because a new serial port value was set during opening new port."); errorStatus = DSMRErrorStatus.PORT_INTERNAL_ERROR; } + } catch (final IllegalStateException ise) { + logger.debug("Failed communicating, probably time out", ise); + + errorStatus = DSMRErrorStatus.PORT_PORT_TIMEOUT; } catch (final IOException ioe) { logger.debug("Failed to get inputstream for serialPort", ioe);