mirror of
https://github.com/espressif/esp-modbus.git
synced 2025-07-30 02:17:17 +02:00
Merge branch 'bugfix/master_fix_getting_stuck_with_one_zero_byte_in_response' into 'master'
serial master: fix getting stuck when just one zero byte in response See merge request idf/esp-modbus!22
This commit is contained in:
@ -85,13 +85,13 @@ void vMBMasterPortSerialEnable(BOOL bRxEnable, BOOL bTxEnable)
|
|||||||
|
|
||||||
static USHORT usMBMasterPortSerialRxPoll(size_t xEventSize)
|
static USHORT usMBMasterPortSerialRxPoll(size_t xEventSize)
|
||||||
{
|
{
|
||||||
BOOL xReadStatus = TRUE;
|
BOOL xStatus = TRUE;
|
||||||
USHORT usCnt = 0;
|
USHORT usCnt = 0;
|
||||||
|
|
||||||
if (bRxStateEnabled) {
|
if (bRxStateEnabled) {
|
||||||
while(xReadStatus && (usCnt++ <= xEventSize)) {
|
while(xStatus && (usCnt++ <= xEventSize)) {
|
||||||
// Call the Modbus stack callback function and let it fill the stack buffers.
|
// Call the Modbus stack callback function and let it fill the stack buffers.
|
||||||
xReadStatus = pxMBMasterFrameCBByteReceived(); // callback to receive FSM
|
xStatus = pxMBMasterFrameCBByteReceived(); // callback to receive FSM
|
||||||
}
|
}
|
||||||
|
|
||||||
// The buffer is transferred into Modbus stack and is not needed here any more
|
// The buffer is transferred into Modbus stack and is not needed here any more
|
||||||
@ -99,7 +99,11 @@ static USHORT usMBMasterPortSerialRxPoll(size_t xEventSize)
|
|||||||
ESP_LOGD(TAG, "Received data: %d(bytes in buffer)\n", (uint32_t)usCnt);
|
ESP_LOGD(TAG, "Received data: %d(bytes in buffer)\n", (uint32_t)usCnt);
|
||||||
#if !CONFIG_FMB_TIMER_PORT_ENABLED
|
#if !CONFIG_FMB_TIMER_PORT_ENABLED
|
||||||
vMBMasterSetCurTimerMode(MB_TMODE_T35);
|
vMBMasterSetCurTimerMode(MB_TMODE_T35);
|
||||||
pxMBMasterPortCBTimerExpired();
|
xStatus = pxMBMasterPortCBTimerExpired();
|
||||||
|
if (!xStatus) {
|
||||||
|
xMBMasterPortEventPost(EV_MASTER_FRAME_RECEIVED);
|
||||||
|
ESP_LOGD(TAG, "Send additional RX ready event.");
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
} else {
|
} else {
|
||||||
ESP_LOGE(TAG, "%s: bRxState disabled but junk data (%d bytes) received. ", __func__, xEventSize);
|
ESP_LOGE(TAG, "%s: bRxState disabled but junk data (%d bytes) received. ", __func__, xEventSize);
|
||||||
|
Reference in New Issue
Block a user