Forum

× 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
  • Fresh Boarder
  • Fresh Boarder
More
2 months 1 week ago - 2 months 1 week 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;
[font=Monaco, Menlo, Consolas, Courier New, monospace]
[/font]
That's all!!!...
Last edit: 2 months 1 week 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 Boarder
  • Junior Boarder
More
2 months 1 week 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