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
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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
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.
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