Menu

Unexpected behavior from ReadArea function

Felipe C
2020-06-05
2021-03-30
  • Felipe C

    Felipe C - 2020-06-05

    Hi,

    I got some problems while testing a client/server application using the Snap7 C++ API on linux. After constinously reading a small set of DBs between two different machines, the values returned turned to be totally messed, e.g. values belonging to DB 1 were shown as part of DB 3.

    At first this problem happened twice only. After reading about some people reporting problems on disconnections here in the forum and a bit of testing I found out that everytime there is a conection link loss the client started to mess read data and turning back to normal operation only after a connection restart.

    The root cause is the retransmission of reading requests sent while the link is down. Beside these reading requests generate a ETIMEDOUT error they remain in the TCP buffer and are transmitted as soon as the link is up again.

    As a workaround I inserted a call to Purge() in the function isoExchangeBuffer to assure the TCP buffer is empty before executing a reading operation.

    Best regards

     
  • HallerbachJ

    HallerbachJ - 2020-12-28

    Hi,

    I am facing the same problem. Where exactly did you place the Purge() call? Did this fix the error for you?

    int TIsoTcpSocket::isoExchangeBuffer(void *Data, int &Size)
    {
        int Result;
    
        ClrIsoError();
        Result =isoSendBuffer(Data, Size);
        if (Result==0)
            Result =isoRecvBuffer(Data, Size);
        return Result;
    }
    

    Thanks in advance!

     
    • Felipe C

      Felipe C - 2021-03-23

      Sorry for the delayed response. I just putted the Purge function in the begining of this function. In all my tests the problem not happened again but as I mentioned it was not a definitive solution to the problem.

       
      • Rajesh P

        Rajesh P - 2021-03-24

        Do I have to include any headers? Where this purge function is defined?

         
        • Felipe C

          Felipe C - 2021-03-30

          The Purge fucntion is defined in sys/snap_msgsock.h. But it is already included in the s7_isotcp.h header file.

           
  • Rajesh P

    Rajesh P - 2021-03-18

    Hi, I am facing similar issue in python using the snap7.dll
    I am seeing lots of TCP Retransmission and TCP OUT OF Order in Wireshark after a few minutes of S7 read request sent from an Embedded system. It responds to all the requests fine for a few minutes and then starts to show Retransmission very frequently.
    Any help is appreciated.

     
  • HallerbachJ

    HallerbachJ - 2021-03-29

    Hi,
    after digging around in the forum, I have found the following solution:
    https://sourceforge.net/p/snap7/discussion/bugfix/thread/de352e4cc2/
    I have modified Snap7 in this way and after that, the error no longer occured.
    Thanks to Felipe and Rousseau for their workarounds.
    Maybe this should find it's way in the official version?

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.