Menu

DBRead bug

2015-02-20
2015-02-24
  • Aleksey Kostromin

    Dear David!

    I've discovered the following bug.

    DBRead method call repeatedly returns the zero byte array.
    Reading occurs every 100ms from PLC Simatic S7-317 2PN/DP.
    I use snap7-bugfix-1.3.0, wrapper for .NET, x86

    Best regards,
    Alexey Kostromin

     
  • Davide Nardella

    Davide Nardella - 2015-02-20

    Hi Alexey,
    What do you mean for returns zero byte array ? The array is filled with all zeros ?
    What result code do you get from the function ?

    Where is defined your array ? It's possible that the garbage collector is not aware that you are using it in unmanaged code ?

    Let me know how I can reproduce the issue.
    If I put a timer onto a form, in your opinion, can I reproduce the issue ? or are you using a very different schema ?

     
  • Davide Nardella

    Davide Nardella - 2015-02-20

    Hi,
    I tested some configurations with subsequent read every 75-100 ms.
    Using both timer and thread, and I never experienced problems (after some thousands of cycles).
    I asked also to some people that are using Snap7 in .net environment for massive data transfer.

    I suggest you to check your source code.

    If the problem persists, please make a tiny .net program that reproduces the issue and send it me.

    Regards
    Dave

     
  • Aleksey Kostromin

    Hi Davide!
    Sorry, but I was mistaken. Actually when I call DBRead everything works fine. But when I call AsDBRead … WaitAsCompletion(timeout) array is filled with all zeros sometimes. Reading every 100ms occurs from another thread.
    This is my code:

            Monitor.Enter(_clientLocker);
    
            try
            {   
                var buffer = new byte[200];
    
                _client.AsDBRead(199, 0, buffer.Length, buffer);
    
                var code = _client.WaitAsCompletion(5000);
    
                if (code != 0)
                {
                    report("Failed to read item (" + item.name + ")! Reason: " + _client.ErrorText(code), MessageType.Fatal, true);
                }
            }
            finally
            {
                Monitor.Exit(_clientLocker);
            }
    

    Is it correct?

    Regards,
    Alexey

     

    Last edit: Aleksey Kostromin 2015-02-24
  • Davide Nardella

    Davide Nardella - 2015-02-24

    So, you have a thread (not listed here) that every 100 ms calls DBRead (or AsDBRead).
    I understand you correctly?

    If yes, you should test the result code of AsDBRead, if it's !=0 it means that the client is busy (because it's reading the thread data).

     

Log in to post a comment.