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] reduce log level when modbus slave returns DEVICE_BUSY exception #3847

Merged
merged 2 commits into from
Apr 28, 2024
Merged
Changes from 1 commit
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 @@ -284,6 +284,12 @@ public void accept(AggregateStopWatch timer, WriteTask task, ModbusSlaveConnecti
*/
private static final String MODBUS_POLLER_THREAD_POOL_NAME = "modbusManagerPollerThreadPool";

/**
* The slave exception code indicating that the device is currently busy processing another
* command.
*/
private static final int MODBUS_EXCEPTION_SLAVE_DEVICE_BUSY = 6;

/**
* Log message with WARN level if the task queues exceed this limit.
*
Expand Down Expand Up @@ -662,7 +668,11 @@ private <R, C extends ModbusResultCallback, F extends ModbusFailureCallback<R>,
} catch (ModbusSlaveException e) {
lastError.set(new ModbusSlaveErrorResponseExceptionImpl(e));
// Slave returned explicit error response, no reason to re-establish new connection
if (willRetry) {
if (willRetry && e.getType() == MODBUS_EXCEPTION_SLAVE_DEVICE_BUSY) {
logger.info(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When re-trying is an expected operation, you can reduce that to DEBUG.

nagisa marked this conversation as resolved.
Show resolved Hide resolved
"Try {} out of {} failed when executing request ({}). The slave device is busy (exception code {}). Will try again soon. [operation ID {}]",
tryIndex, maxTries, request, e.getType(), operationId);
} else if (willRetry) {
logger.warn(
"Try {} out of {} failed when executing request ({}). Will try again soon. Error was: {} {} [operation ID {}]",
tryIndex, maxTries, request, e.getClass().getName(), e.getMessage(), operationId);
Expand Down