diff --git a/subsys/modbus/modbus_serial.c b/subsys/modbus/modbus_serial.c index 32aa525ad8d..0289c001bc6 100644 --- a/subsys/modbus/modbus_serial.c +++ b/subsys/modbus/modbus_serial.c @@ -362,7 +362,14 @@ static void cb_handler_tx(struct modbus_context *ctx) cfg->uart_buf_ctr); cfg->uart_buf_ctr -= n; cfg->uart_buf_ptr += n; - } else { + return; + } + + /* Must wait till the transmission is complete or + * RS-485 tranceiver could be disabled before all data has + * been transmitted and message will be corrupted. + */ + if (uart_irq_tx_complete(cfg->dev)) { /* Disable transmission */ cfg->uart_buf_ptr = &cfg->uart_buf[0]; modbus_serial_tx_off(ctx);