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

Bug or logical oversight #1

Open
adem0x opened this issue Aug 26, 2017 · 1 comment
Open

Bug or logical oversight #1

adem0x opened this issue Aug 26, 2017 · 1 comment

Comments

@adem0x
Copy link

adem0x commented Aug 26, 2017

I am trying to get PascalSCADA to compile with both D7 and Tokyo. Except for the HMI stuff, I have managed the rest to compile.

While doing that, Tokyo highlighted a potential bug, or a logical error in 2 routines.

Namely,

in function TMelsecDriver.DoRead()

        if FRemainingBytes > 0 then begin
          res := PCommPort.IOCommandSync(iocRead, 0, nil, FRemainingBytes, DriverID, 0, @IOResult2, starts, ends);

          if res <> 0 then begin
            IOResult1.BufferToRead := ConcatenateBytes(IOResult1.BufferToRead, IOResult2.BufferToRead);
            IOResult1.Received := IOResult1.Received + IOResult2.Received;
            if IOResult2.ReadIOResult <> iorOK then IOResult1.ReadIOResult := IOResult2.ReadIOResult;
          end else Result := ioDriverError;
        end;
        Result := DecodePkg(IOResult1, values);

shouln't it be

        if FRemainingBytes > 0 then begin
          res := PCommPort.IOCommandSync(iocRead, 0, nil, FRemainingBytes, DriverID, 0, @IOResult2, starts, ends);

          if res <> 0 then begin
            IOResult1.BufferToRead := ConcatenateBytes(IOResult1.BufferToRead, IOResult2.BufferToRead);
            IOResult1.Received := IOResult1.Received + IOResult2.Received;
            if IOResult2.ReadIOResult <> iorOK then IOResult1.ReadIOResult := IOResult2.ReadIOResult;
            Result := DecodePkg(IOResult1, values); <<<---- HERE
          end else Result := ioDriverError;
        end;

similarly

in function TMelsecDriver.DoWrite()

        if FRemainingBytes > 0 then begin
          res := PCommPort.IOCommandSync(iocRead, 0, nil, FRemainingBytes, DriverID, 0, @IOResult2);

          if res <> 0 then begin
            IOResult1.BufferToRead := ConcatenateBytes(IOResult1.BufferToRead, IOResult2.BufferToRead);
            IOResult1.Received := IOResult1.Received + IOResult2.Received;
            if IOResult2.ReadIOResult <> iorOK then IOResult1.ReadIOResult := IOResult2.ReadIOResult;
          end else Result := ioDriverError;
        end;
        Result := DecodePkg(IOResult1, tempValues);
      end else Result := ioEmptyPacket;

shouln't it be

        if FRemainingBytes > 0 then begin
          res := PCommPort.IOCommandSync(iocRead, 0, nil, FRemainingBytes, DriverID, 0, @IOResult2);

          if res <> 0 then begin
            IOResult1.BufferToRead := ConcatenateBytes(IOResult1.BufferToRead, IOResult2.BufferToRead);
            IOResult1.Received := IOResult1.Received + IOResult2.Received;
            if IOResult2.ReadIOResult <> iorOK then IOResult1.ReadIOResult := IOResult2.ReadIOResult;
            Result := DecodePkg(IOResult1, tempValues);  <<<---- HERE
          end else Result := ioDriverError;
        end;
      end else Result := ioEmptyPacket;

@fluisgirardi
Copy link
Owner

Hi!

Thanks by your feedback. Please attach the patch with these changes.

If you can, send me the entire package that you have modified to work with latest delphi versions, to share it with others.

This page is for the new version, that's not ready yet. So, if you found new issues related with 0.7.x versions, report it on Sourceforge ( https://sourceforge.net/projects/pascalscada/ ), and in last cases, here. For now, continue this issue here.

Thanks again by your feedback.

The best regards,
Fabio

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

2 participants