Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

InputBuffer noty cleared after timeout #42

Open
thomsentaastrup opened this issue May 6, 2020 · 0 comments
Open

InputBuffer noty cleared after timeout #42

thomsentaastrup opened this issue May 6, 2020 · 0 comments

Comments

@thomsentaastrup
Copy link

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;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant