Menu

CLI: Job Pending

Instamed
2015-06-18
2015-06-18
  • Instamed

    Instamed - 2015-06-18

    Hello!
    First of all I would like to thank you for your good job Davide.

    Well, i have some questions:

    I have two clients connected with a s7 300. They are connected when inits app and never disconnect.
    One client is in thread writing in loop values to a dw.
    Other one is reading that's values and presenting.

    Sometimes when reading in syncronous mode (ReadArea) i receive error messages of "CLI: Job Pending".
    Why? i supose that these errors are present in async calls...

    Also when i unplug ethernet cable or switching clp to OFF for testing errors connection, never reconnects...
    How can i solve this?

    Thanks

    Release : 1.4
    OS : Windows 8.1
    CPU : x64
    Wrapper : dot.net -> snap7.net.cs

     
  • Davide Nardella

    Davide Nardella - 2015-06-18

    Hi,
    Snap7 library is object oriented all resources are inside the classes and there are no global vars.

    Your error has not sense in a sync call.
    Are you completely and absolutely sure that you are not mess with your classes ?

    That said, the class itself (for optimization reasons) is not thread safe : accessing the same class contemporary from two different threads can lead your problem.


    Snap7 client is a low-level driver, to detect and recover network errors you should insert your operations in a thread checking the TCP error:

    A simply fast pascal code:

    // While cycle inside the thread body, Terminated is a boolean which indicates that
    // the thread must exit
    while not Terminated do
    begin

    if not Client.Connected then
    begin
    repeat
    sleep(500); // try to reconnect every 500 ms
    until (Client.Connect=0) or Terminated;
    end;

    if not Terminated then
    DoSomethingWithClient;

    // Check if the low part of the error is a TCP error
    if (Client.LastError and $0000FFFF)<>0 then
    Client.Disconnect;

    end;

    You can look also to the S7partner c++ code which uses the same mechanism to automatically reconnect.

     

    Last edit: Davide Nardella 2015-06-18

Log in to post a comment.

MongoDB Logo MongoDB