Skip to content

Commit

Permalink
[modbus] Clarifying error messages with invalid configuration (openha…
Browse files Browse the repository at this point in the history
…b#11292)

Resolves openhab#10814

Signed-off-by: Sami Salonen <ssalonen@gmail.com>
Signed-off-by: Dave J Schoepel <dave@theschoepels.com>
  • Loading branch information
ssalonen authored and dschoepel committed Nov 9, 2021
1 parent 26e6064 commit 6940085
Showing 1 changed file with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -718,11 +718,14 @@ private void validateReadIndex() throws ModbusConfigurationException {
}

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
Expand Down

0 comments on commit 6940085

Please sign in to comment.