From 7b1c44547e0225a333b2b102793fab1f0f300f48 Mon Sep 17 00:00:00 2001 From: Holger Friedrich Date: Sun, 24 Nov 2024 10:19:33 +0100 Subject: [PATCH] [knx] Improve logging for serial gateways (#17793) * Logger in SerialAdapter respects the log setting for the binding. * Additional warning if open port is detected. Signed-off-by: Holger Friedrich --- .../binding/knx/internal/client/SerialTransportAdapter.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/bundles/org.openhab.binding.knx/src/main/java/org/openhab/binding/knx/internal/client/SerialTransportAdapter.java b/bundles/org.openhab.binding.knx/src/main/java/org/openhab/binding/knx/internal/client/SerialTransportAdapter.java index c04a4a4aece..8238fbd93a7 100644 --- a/bundles/org.openhab.binding.knx/src/main/java/org/openhab/binding/knx/internal/client/SerialTransportAdapter.java +++ b/bundles/org.openhab.binding.knx/src/main/java/org/openhab/binding/knx/internal/client/SerialTransportAdapter.java @@ -74,7 +74,7 @@ public class SerialTransportAdapter implements SerialCom { if (portId == null) { throw new IOException("Port not available"); } - logger = LoggerFactory.getLogger("SerialTransportAdapter:" + portId); + logger = LoggerFactory.getLogger(SerialTransportAdapter.class.getName() + ":" + portId); final @Nullable SerialPortManager tmpSerialPortManager = serialPortManager; if (tmpSerialPortManager == null) { @@ -83,6 +83,10 @@ public class SerialTransportAdapter implements SerialCom { try { SerialPortIdentifier portIdentifier = tmpSerialPortManager.getIdentifier(portId); if (portIdentifier != null) { + if (portIdentifier.isCurrentlyOwned()) { + logger.warn("Configured port {} is currently in use by another application: {}", portId, + portIdentifier.getCurrentOwner()); + } logger.trace("Trying to open port {}", portId); SerialPort serialPort = portIdentifier.open(this.getClass().getName(), OPEN_TIMEOUT_MS); // apply default settings for com port, may be overwritten by caller