05-27-2009 10:44 AM
Hi Everyone,
I have a large VI that uses modbus tcp/ip to communicate with a remote sensor. The problem is that is that if I disconnect the network cable or switch the power off to the sensor I get an error 56 from tcp read, or I get error 66 from TCP write. but I can not find away of clearing the error and re-estalishing the connection other than stopping and starting the VI. Does anyone have any ideas as to where I can find what these errors mean, or better still how to deal with them.
Thanks in advance for any assistance.
Derek
05-27-2009 01:01 PM
05-28-2009 08:58 AM - edited 05-28-2009 08:59 AM
Hi,
Thanks for that... that was a lot simpler than I thought it was going to be.
I did as you said and then, if I disconnected the power to the slave and re-connected, the connection would re-establish and all was well. If however I pulled the network connection out wait for an error , then plug the network back in, wouldn't re-connect. If I then cyled the power to the sensor, the connection would re-establish. If I stopped the VI and restarted it I could re-connect. What seems to have "fixed" the problem is if I close the connection befor I open it. I know that sounds a bit odd but it seems to have worked. I have attached the VI to this post. If anyone has any explanation or comments please let me know.
Thanks again for your help
Derek
05-28-2009 09:57 AM
05-28-2009 10:20 AM
I guess somewhere in my head the connection being "lost" is the same as being closed. I guess if you wouldn't try and open a com port without making sure it was closed so it makes sense.
Derek
06-02-2009 04:32 AM
Hi there, me again.
Made a lot of progress with this. What I've done is when I see a connection error I close the connection, then open a new one a second later, with the same IP and port number. This works, but if I disconnect the network connection until the VI errors, then re-connect, I get an error 60 for almost exactly 2 mins then it re-connects. It does this every time.
Although I've not been able to find a definitive explanation for this, I found this
http://digital.ni.com/public.nsf/allkb/119D334B8B78732E862574E1006D1839
Which suggests that my client is in a Time Wait State, is this something that is fixed within the client, do I just have to live with this or is there a way I can 'force' the connection to timeout? I'm off to try and find this out, but if anyone has any ideas that might help point me in the right direction I'd appreciate it.
Thanks again
Derek