Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[modbus] Improve error message if data thing is configured for reading but not connected to a polling bridge. #16054

Merged
merged 1 commit into from
Dec 14, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -423,8 +423,7 @@ public synchronized void initialize() {
childOfEndpoint = true;
functionCode = null;
readRequest = null;
} else {
ModbusPollerThingHandler localPollerHandler = (ModbusPollerThingHandler) bridgeHandler;
} else if (bridgeHandler instanceof ModbusPollerThingHandler localPollerHandler) {
pollerHandler = localPollerHandler;
ModbusReadRequestBlueprint localReadRequest = localPollerHandler.getRequest();
if (localReadRequest == null) {
Expand All @@ -441,7 +440,12 @@ public synchronized void initialize() {
comms = localPollerHandler.getCommunicationInterface();
pollStart = localReadRequest.getReference();
childOfEndpoint = false;
} else {
ssalonen marked this conversation as resolved.
Show resolved Hide resolved
String errmsg = String.format("Thing %s is connected to an unsupported type of bridge.",
getThing().getUID());
throw new ModbusConfigurationException(errmsg);
}

validateAndParseReadParameters(localConfig);
validateAndParseWriteParameters(localConfig);
validateMustReadOrWrite();
Expand Down Expand Up @@ -513,8 +517,8 @@ private void validateAndParseReadParameters(ModbusDataConfiguration config) thro
if (childOfEndpoint && readRequest == null) {
if (!readStartMissing || !readValueTypeMissing) {
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)!",
getThing().getUID(), config.getReadStart(), config.getReadValueType());
"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());
throw new ModbusConfigurationException(errmsg);
}
}
Expand Down