You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When reading two or more different register blocks for one dataset and a timeout on a reading occurs then you get the data from the previous block for all the following readings. This is due to the inputbuffer is not cleared. It should be considered to clear the input buffer in all the read procedures.
This code from production show how we do from now on.
function TModBusCom.ReadInputRegisters(RegisterStart, Count: Word): Boolean;
begin
Result := False;
try
// Avoid reading previous data after a read timeout
if FmbClient.Connected then
FmbClient.IOHandler.InputBuffer.Clear;
Result := FmbClient.ReadInputRegisters(RegisterStart, Count, FRegisterData);
except
on E: EIdException do
ModBusError(ModBus_etIndyException, ModBus_ftNotUsed, E.Message);
end;
if Result then
ParseData(mbfReadInputRegs, RegisterStart, Count);
end;
The text was updated successfully, but these errors were encountered:
When reading two or more different register blocks for one dataset and a timeout on a reading occurs then you get the data from the previous block for all the following readings. This is due to the inputbuffer is not cleared. It should be considered to clear the input buffer in all the read procedures.
This code from production show how we do from now on.
function TModBusCom.ReadInputRegisters(RegisterStart, Count: Word): Boolean;
begin
Result := False;
try
// Avoid reading previous data after a read timeout
if FmbClient.Connected then
FmbClient.IOHandler.InputBuffer.Clear;
Result := FmbClient.ReadInputRegisters(RegisterStart, Count, FRegisterData);
except
on E: EIdException do
ModBusError(ModBus_etIndyException, ModBus_ftNotUsed, E.Message);
end;
if Result then
ParseData(mbfReadInputRegs, RegisterStart, Count);
end;
The text was updated successfully, but these errors were encountered: