Menu

Issue on Client->Connected() function

mc
2018-04-06
2018-04-12
  • mc

    mc - 2018-04-06

    Hello everybody.
    I am experiencing issues on the Client->Connected() function on a s7-1500 CPU.
    Using the bleow piece of code:

    while (!TerminateCondition())
    {
    if (Client->Connected())
    {
    PerformDataExchange();
    sleep(TimeRate); // exchange time interval
    }
    else
    if (Client->Connect()!=0)
    sleep(10); // small wait recovery time
    }

    I am able to connect and read without any issue.
    When I unplug the ethernet cable from the CPU, the Client->Connected() keeps returning true value, so it does not recognize that the PLC has been disconnected.

    Any suggestion how to fix it?

    Thanks in advance

     
  • Davide Nardella

    Davide Nardella - 2018-04-06

    Hi,
    Connected flag is only a "reminder" to remember if you connected your client.
    There is no way for a client (a generic TCP/IP client, not only Snap7) to know that tha cable was disconnected until you try to communicate.
    Try to implement a polling.

     
  • mc

    mc - 2018-04-12

    Thank you, I thought the function Connected() was handling a request to the PLC to check the connection status.
    I was able to work with no issues using by monitoring the status of the PLC.

    Thanks again

     

Log in to post a comment.