modbus: Fixed serial RX enablement for ASYNC and client mode

Modbus is failing to turn on RX when using serial ASYNC mode. This
causes modbus to never receive inbound requests, leaving it inoperable.
Additionally, modbus also enables RX when in client mode, leading to
issues when running as a client. These have been fixed by enabling rx
only when serial init is successful and modbus is in server mode during
initialisation.

Signed-off-by: Ryan Wiebe <ryan.wiebe@analog.com>
This commit is contained in:
Ryan Wiebe
2026-01-20 11:53:30 +00:00
committed by Henrik Brix Andersen
parent b76f37c5da
commit 8135c56cf6

View File

@@ -693,10 +693,13 @@ int modbus_serial_init(struct modbus_context *ctx,
if (!err) {
k_timer_init(&cfg->rtu_timer, rtu_tmr_handler, NULL);
k_timer_user_data_set(&cfg->rtu_timer, ctx);
modbus_serial_rx_on(ctx);
}
}
if (!err && !ctx->client) {
modbus_serial_rx_on(ctx);
}
LOG_INF("RTU timeout %u us", cfg->rtu_timeout);
return err;