From 2fb38d0994564cb05efd6da261bc33eeb75f97d7 Mon Sep 17 00:00:00 2001 From: Wouter Born Date: Mon, 7 Sep 2020 12:52:17 +0200 Subject: [PATCH] [dsmr] Catch exceptions for RFC2217 compatibility (#8420) Signed-off-by: Wouter Born --- .../device/connector/DSMRSerialConnector.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) 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 16e1743057440..62462583438f3 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 @@ -155,8 +155,16 @@ public void open(DSMRSerialSettings portSettings) { serialPort.notifyOnOverrunError(true); serialPort.notifyOnParityError(true); - serialPort.enableReceiveThreshold(SERIAL_TIMEOUT_MILLISECONDS); - serialPort.enableReceiveTimeout(SERIAL_TIMEOUT_MILLISECONDS); + try { + serialPort.enableReceiveThreshold(SERIAL_TIMEOUT_MILLISECONDS); + } catch (UnsupportedCommOperationException e) { + logger.debug("Enable receive threshold is unsupported"); + } + try { + serialPort.enableReceiveTimeout(SERIAL_TIMEOUT_MILLISECONDS); + } catch (UnsupportedCommOperationException e) { + logger.debug("Enable receive timeout is unsupported"); + } // The binding is ready, let the meter know we want to receive values serialPort.setRTS(true); if (!serialPortReference.compareAndSet(oldSerialPort, serialPort)) {