× Components and Libraries for HMI/SCADA applications, discussions, problems and suggestions

Question Bug found and fixed on ModbusTCP.pas

  • Marco Pinero
  • Marco Pinero's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
3 years 2 weeks ago - 3 years 2 weeks ago #12745 by Marco Pinero
Bug found and fixed on ModbusTCP.pas was created by Marco Pinero
Hi all.

I got this bug at modbustcp.pas from pl_PascalScada:

At line 410 Codetyphon has this code:
       // data are ok
        for i:=0 to Len-1 do begin
          if (10+i*20)<Length(pkg.BufferToRead) then
            Values[i]:=(LongInt(pkg.BufferToRead[9+(i*2)]) shl 8) + LongInt(pkg.BufferToRead[10+i*2])
          else
            Values[i]:=0
        end;
I solved it doing this:
   // data are ok
        for i:=0 to Len-1 do begin
          if (10+i*2)<Length(pkg.BufferToRead) then  (*<---- it is not I*20 (it is jumping 20 bytes and that's not correct) it must be I*2) *)
            Values[i]:=(LongInt(pkg.BufferToRead[9+(i*2)]) shl 8) + LongInt(pkg.BufferToRead[10+i*2])
          else
            Values[i]:=0
        end;


That's all!!!...
Last edit: 3 years 2 weeks ago by Marco Pinero. Reason: Bad text indentation

Please Log in or Create an account to join the conversation.

  • Fabio Luis Girardi
  • Fabio Luis Girardi's Avatar
  • Offline
  • Junior Member
  • Junior Member
More
3 years 2 weeks ago #12746 by Fabio Luis Girardi
Replied by Fabio Luis Girardi on topic Bug found and fixed on ModbusTCP.pas
I already have fixed this in Pascalscada repository, some days ago.

Thanks by your feedback!

Please Log in or Create an account to join the conversation.

Moderators: Curt