12-03-2012 11:06 AM
In my application, I am communicating with a PLC thru RS Linx utilizing a data socket. I can successfully open the socket, write the value and update using the following:
DS_Open with DSConst_Write option
DS_SetDataValue and then DS_Update
For robustness, I want to be able to alert the operator if the ethernet cable attaching the PC to PLC is unplugged, most likely or some other portion of the process has failed, less likely once setup.
I do have a solution to the above, but what I have found is that if during the execution of my program I disconnect the cable, DS_Update does give me an error indicating that sometheing is wrong, but my code hangs the thread for an indeterminate amount of time at least 1 second either through the execution of the DS_SetDataValue cmd or DS_Update. Both commands don't have a timeout associated with them, but is there some default timeout that is used.
As a work around, my thought is that I if available I could use feedback from a callback if fast enough which can detect when a network cable has been disconnected to avoid this indeterminate timeout by avoiding any set or update commands when the cable is not connected.
12-04-2012 10:05 AM
Hi testguy,
Have you tried some of the other data socket functions? DS_IsConnected or DS_GetStatus may be able to tell the status of the connection a little faster; you could run one of those before the DS_Update so it doesn't hang. The full list of data socket functions can be seen here .
There are also some other communication protocols that do allow timeout configuration, like telnet, TCP, and UDP.
Hope this helps!
-Alexandra