diff --git a/yaMBSiavr.c b/yaMBSiavr.c index 2d8a15f..1ca7638 100644 --- a/yaMBSiavr.c +++ b/yaMBSiavr.c @@ -125,14 +125,15 @@ void modbusTickTimer(void) { if ((modbusTimer==modbusInterCharTimeout)) { BusState|=(1< perform crc check - BusState=(1<=requestedAmount) && ((DataPos-9)==rxbuffer[6])) //enough data received? + if (((rxbuffer[6])>=requestedAmount*2) && ((DataPos-9)>=rxbuffer[6])) //enough data received? { modbusRegisterToInt(rxbuffer+7,ptrToInArray+(unsigned char)(requestedAdr-startAddress),(unsigned char)(requestedAmount)); modbusSendMessage(5); @@ -322,7 +323,7 @@ uint8_t modbusExchangeBits(volatile uint8_t *ptrToInArray, uint16_t startAddress } else if (rxbuffer[1]==fcForceMultipleCoils) { - if (((rxbuffer[6]*8)>=requestedAmount) && ((DataPos-9)==rxbuffer[6])) //enough data received? + if (((rxbuffer[6]*8)>=requestedAmount) && ((DataPos-9)>=rxbuffer[6])) //enough data received? { for (uint16_t c = 0; c