Update mbrtu_m.c

Master模式下,接收缓冲区的索引在“接收到第一个字节”时重置修改为“开启发送”时重置
This commit is contained in:
俞敏涛 2020-03-26 19:21:38 +08:00
parent 49375ebf5b
commit a486f7a684
1 changed files with 2 additions and 1 deletions

View File

@ -204,6 +204,8 @@ eMBMasterRTUSend( UCHAR ucSlaveAddress, const UCHAR * pucFrame, USHORT usLength
*/
if( eRcvState == STATE_M_RX_IDLE )
{
usMasterRcvBufferPos = 0;
/* First byte before the Modbus-PDU is the slave address. */
pucMasterSndBufferCur = ( UCHAR * ) pucFrame - 1;
usMasterSndBufferCount = 1;
@ -268,7 +270,6 @@ xMBMasterRTUReceiveFSM( void )
vMBMasterPortTimersDisable( );
eSndState = STATE_M_TX_IDLE;
usMasterRcvBufferPos = 0;
ucMasterRTURcvBuf[usMasterRcvBufferPos++] = ucByte;
eRcvState = STATE_M_RX_RCV;