mirror of
https://github.com/espressif/esp-modbus.git
synced 2025-07-29 18:07:17 +02:00
serial master: fix getting stuck when just one zero byte in response
This commit is contained in:
@ -85,13 +85,13 @@ void vMBMasterPortSerialEnable(BOOL bRxEnable, BOOL bTxEnable)
|
||||
|
||||
static USHORT usMBMasterPortSerialRxPoll(size_t xEventSize)
|
||||
{
|
||||
BOOL xReadStatus = TRUE;
|
||||
BOOL xStatus = TRUE;
|
||||
USHORT usCnt = 0;
|
||||
|
||||
if (bRxStateEnabled) {
|
||||
while(xReadStatus && (usCnt++ <= xEventSize)) {
|
||||
while(xStatus && (usCnt++ <= xEventSize)) {
|
||||
// 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
|
||||
@ -99,7 +99,11 @@ static USHORT usMBMasterPortSerialRxPoll(size_t xEventSize)
|
||||
ESP_LOGD(TAG, "Received data: %d(bytes in buffer)\n", (uint32_t)usCnt);
|
||||
#if !CONFIG_FMB_TIMER_PORT_ENABLED
|
||||
vMBMasterSetCurTimerMode(MB_TMODE_T35);
|
||||
pxMBMasterPortCBTimerExpired();
|
||||
xStatus = pxMBMasterPortCBTimerExpired();
|
||||
if (!xStatus) {
|
||||
xMBMasterPortEventPost(EV_MASTER_FRAME_RECEIVED);
|
||||
ESP_LOGD(TAG, "Send additional RX ready event.");
|
||||
}
|
||||
#endif
|
||||
} else {
|
||||
ESP_LOGE(TAG, "%s: bRxState disabled but junk data (%d bytes) received. ", __func__, xEventSize);
|
||||
|
Reference in New Issue
Block a user