coassoftwaresystems / delphi-modbus

Delphi ModbusTCP components
114 stars 61 forks source link

ReadCoils Errors #18

Closed federico32 closed 7 years ago

federico32 commented 7 years ago

Hi. On IdModBusServer, when we try read more than 112 coils; on PutCoilsIntoBuffer raise this exception if (Length(data) < Count - 1) or (Length(data)=0) or (Count = 0) then begin raise exception.Create('PutCoilsIntoBuffer Data Length error '); end;

is this correct ? Is only 5 word read by time ?

Thank you

plpolak commented 7 years ago

The check is not correct. You should be able to read up to 2000 coils (125 words can be read at a time).

This is the correct check: if (Length(Data) < ((Count div 16) - 1)) or (Length(Data) = 0) or (Count = 0) then