[modbus] Improve error message if data thing is configured for reading but not connected to a polling bridge. (#16054)
Signed-off-by: Markus Minichmayr <markus@minichmayr.net>
This commit is contained in:
parent
4f84c48b21
commit
03b7b1dbac
|
@ -423,8 +423,7 @@ public class ModbusDataThingHandler extends BaseThingHandler {
|
||||||
childOfEndpoint = true;
|
childOfEndpoint = true;
|
||||||
functionCode = null;
|
functionCode = null;
|
||||||
readRequest = null;
|
readRequest = null;
|
||||||
} else {
|
} else if (bridgeHandler instanceof ModbusPollerThingHandler localPollerHandler) {
|
||||||
ModbusPollerThingHandler localPollerHandler = (ModbusPollerThingHandler) bridgeHandler;
|
|
||||||
pollerHandler = localPollerHandler;
|
pollerHandler = localPollerHandler;
|
||||||
ModbusReadRequestBlueprint localReadRequest = localPollerHandler.getRequest();
|
ModbusReadRequestBlueprint localReadRequest = localPollerHandler.getRequest();
|
||||||
if (localReadRequest == null) {
|
if (localReadRequest == null) {
|
||||||
|
@ -441,7 +440,12 @@ public class ModbusDataThingHandler extends BaseThingHandler {
|
||||||
comms = localPollerHandler.getCommunicationInterface();
|
comms = localPollerHandler.getCommunicationInterface();
|
||||||
pollStart = localReadRequest.getReference();
|
pollStart = localReadRequest.getReference();
|
||||||
childOfEndpoint = false;
|
childOfEndpoint = false;
|
||||||
|
} else {
|
||||||
|
String errmsg = String.format("Thing %s is connected to an unsupported type of bridge.",
|
||||||
|
getThing().getUID());
|
||||||
|
throw new ModbusConfigurationException(errmsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
validateAndParseReadParameters(localConfig);
|
validateAndParseReadParameters(localConfig);
|
||||||
validateAndParseWriteParameters(localConfig);
|
validateAndParseWriteParameters(localConfig);
|
||||||
validateMustReadOrWrite();
|
validateMustReadOrWrite();
|
||||||
|
@ -513,8 +517,8 @@ public class ModbusDataThingHandler extends BaseThingHandler {
|
||||||
if (childOfEndpoint && readRequest == null) {
|
if (childOfEndpoint && readRequest == null) {
|
||||||
if (!readStartMissing || !readValueTypeMissing) {
|
if (!readStartMissing || !readValueTypeMissing) {
|
||||||
String errmsg = String.format(
|
String errmsg = String.format(
|
||||||
"Thing %s readStart=%s, and readValueType=%s were specified even though the data thing is child of endpoint (that is, write-only)!",
|
"Thing %s was configured for reading (readStart and/or readValueType specified) but the parent is not a polling bridge. Consider using a bridge of type 'Regular Poll'.",
|
||||||
getThing().getUID(), config.getReadStart(), config.getReadValueType());
|
getThing().getUID());
|
||||||
throw new ModbusConfigurationException(errmsg);
|
throw new ModbusConfigurationException(errmsg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue