Skip to content

Commit

Permalink
freemodbus: fix uart_wait_tx_done() reenable tx_done interrupt
Browse files Browse the repository at this point in the history
fixes the issue with uart_wait_tx_done() when the task is suspended and transmission is done right before reenable tx_done interrupt


* Original commit: espressif/esp-idf@c801b3a
  • Loading branch information
alisitsyn committed Mar 21, 2022
1 parent 5a27d03 commit c0163bb
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion components/freemodbus/port/port.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
#define MB_SERIAL_BUF_SIZE (CONFIG_FMB_SERIAL_BUF_SIZE)

// common definitions for serial port implementations
#define MB_SERIAL_TX_TOUT_MS (100)
#define MB_SERIAL_TX_TOUT_MS (2200) // maximum time for transmission of longest allowed frame buffer
#define MB_SERIAL_TX_TOUT_TICKS (pdMS_TO_TICKS(MB_SERIAL_TX_TOUT_MS)) // timeout for transmission
#define MB_SERIAL_RX_TOUT_MS (1)
#define MB_SERIAL_RX_TOUT_TICKS (pdMS_TO_TICKS(MB_SERIAL_RX_TOUT_MS)) // timeout for receive
Expand Down
2 changes: 1 addition & 1 deletion components/freemodbus/port/portserial_m.c
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ BOOL xMBMasterPortSerialTxPoll(void)
ESP_LOGD(TAG, "MB_TX_buffer sent: (%d) bytes.", (uint16_t)(usCount - 1));
// Waits while UART sending the packet
esp_err_t xTxStatus = uart_wait_tx_done(ucUartNumber, MB_SERIAL_TX_TOUT_TICKS);
vMBMasterPortSerialEnable( TRUE, FALSE );
vMBMasterPortSerialEnable(TRUE, FALSE);
MB_PORT_CHECK((xTxStatus == ESP_OK), FALSE, "mb serial sent buffer failure.");
return TRUE;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ static void modbus_master_task(void *pvParameters)
// Send response buffer if ready to be sent
BOOL xSentState = xMBMasterPortSerialTxPoll();
if (xSentState) {
// Let state machine know that response was transmitted out
// Let state machine know that request frame was transmitted out
(void)xMBMasterPortEventPost(EV_MASTER_FRAME_SENT);
}
}
Expand Down

0 comments on commit c0163bb

Please sign in to comment.