modbus: serial: Fix incomplete transmission issue
This patch is to fix an issue where the transceiver chip is disabled before it has transmitted all data. This causes the message to be corrupted because the last few bytes are missing. The fix adds a check to make sure the transmission is completed before disabling the transceiver. Signed-off-by: Marius Scholtz <mariuss@ricelectronics.com>
This commit is contained in:
parent
4855e8ded1
commit
3ea5343f0d
1 changed files with 8 additions and 1 deletions
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue