From 822c27c181aa1b91e9c1cdec511c5d7bff66a595 Mon Sep 17 00:00:00 2001 From: Holger Friedrich Date: Sun, 19 Jun 2022 14:50:35 +0200 Subject: [PATCH] [knx] FT12: List available serial ports if port cannot be opened (#12942) Fixes a regression introduced by upgrading Calimero library to 2.5. Signed-off-by: Holger Friedrich --- .../openhab/binding/knx/internal/client/SerialClient.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/bundles/org.openhab.binding.knx/src/main/java/org/openhab/binding/knx/internal/client/SerialClient.java b/bundles/org.openhab.binding.knx/src/main/java/org/openhab/binding/knx/internal/client/SerialClient.java index 2a49d5d2d..ce1d0c342 100644 --- a/bundles/org.openhab.binding.knx/src/main/java/org/openhab/binding/knx/internal/client/SerialClient.java +++ b/bundles/org.openhab.binding.knx/src/main/java/org/openhab/binding/knx/internal/client/SerialClient.java @@ -36,6 +36,8 @@ import tuwien.auto.calimero.link.medium.TPSettings; @NonNullByDefault public class SerialClient extends AbstractKNXClient { + private static final String CALIMERO_ERROR_CANNOT_OPEN_PORT = "failed to open serial port"; + private final Logger logger = LoggerFactory.getLogger(SerialClient.class); private final String serialPort; @@ -69,7 +71,8 @@ public class SerialClient extends AbstractKNXClient { e); } catch (KNXException e) { final String msg = e.getMessage(); - if ((msg != null) && (msg.startsWith("can not open serial port"))) { + // TODO add a test for this string match; error message might change in later version of Calimero library + if ((msg != null) && (msg.startsWith(CALIMERO_ERROR_CANNOT_OPEN_PORT))) { StringBuilder sb = new StringBuilder("Available ports are:\n"); Enumeration portList = CommPortIdentifier.getPortIdentifiers(); while (portList.hasMoreElements()) {