From 22e8a37ee97f44a0cd018513195dc92c8b209392 Mon Sep 17 00:00:00 2001 From: Sami Salonen Date: Mon, 11 Oct 2021 13:41:35 +0300 Subject: [PATCH] [modbus] Clarifying error messages with invalid configuration (#11292) Resolves #10814 Signed-off-by: Sami Salonen --- .../modbus/internal/handler/ModbusDataThingHandler.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/bundles/org.openhab.binding.modbus/src/main/java/org/openhab/binding/modbus/internal/handler/ModbusDataThingHandler.java b/bundles/org.openhab.binding.modbus/src/main/java/org/openhab/binding/modbus/internal/handler/ModbusDataThingHandler.java index d1b03d1c1da..4a83ef83a7f 100644 --- a/bundles/org.openhab.binding.modbus/src/main/java/org/openhab/binding/modbus/internal/handler/ModbusDataThingHandler.java +++ b/bundles/org.openhab.binding.modbus/src/main/java/org/openhab/binding/modbus/internal/handler/ModbusDataThingHandler.java @@ -718,11 +718,14 @@ public class ModbusDataThingHandler extends BaseThingHandler { } if (valueTypeBitCount >= 16 && readSubIndex.isPresent()) { - String errmsg = String - .format("readStart=X.Y is not allowed to be used with value types larger than 16bit!"); + String errmsg = String.format( + "readStart=X.Y notation is not allowed to be used with value types larger than 16bit! Use readStart=X instead."); throw new ModbusConfigurationException(errmsg); } else if (!bitQuery && valueTypeBitCount < 16 && !readSubIndex.isPresent()) { - String errmsg = String.format("readStart=X.Y must be used with value types less than 16bit!"); + // User has specified value type which is less than register width (16 bits). + // readStart=X.Y notation must be used to define which data to extract from the 16 bit register. + String errmsg = String + .format("readStart=X.Y must be used with value types (readValueType) less than 16bit!"); throw new ModbusConfigurationException(errmsg); } else if (readSubIndex.isPresent() && (readSubIndex.get() + 1) * valueTypeBitCount > 16) { // the sub index Y (in X.Y) is above the register limits