diff --git a/FreeModbus/modbus/functions/mbfuncholding.c b/FreeModbus/modbus/functions/mbfuncholding.c index e74a062..7921302 100644 --- a/FreeModbus/modbus/functions/mbfuncholding.c +++ b/FreeModbus/modbus/functions/mbfuncholding.c @@ -183,7 +183,7 @@ eMBFuncReadHoldingRegister( UCHAR * pucFrame, USHORT * usLen ) usRegAddress++; usRegCount = ( USHORT )( pucFrame[MB_PDU_FUNC_READ_REGCNT_OFF] << 8 ); - usRegCount = ( USHORT )( pucFrame[MB_PDU_FUNC_READ_REGCNT_OFF + 1] ); + usRegCount |= ( USHORT )( pucFrame[MB_PDU_FUNC_READ_REGCNT_OFF + 1] ); /* Check if the number of registers to read is valid. If not * return Modbus illegal data value exception.