Thang Nguyen Posted February 16, 2007 Report Share Posted February 16, 2007 Hi, I am currently working on a project which acquires data from different of devices. They are connected by serial, ethernet communication. I think about the case that in the operation the connection may be disconnected. I am thinking a method to handle this case. I am still new in the industry application so I don't have much experience about this issue. Please give me some idea about sloving this problem. Thank you in advance for your time reading and answering this topic. Thang Nguyen Quote Link to comment
Rolf Kalbermatter Posted February 17, 2007 Report Share Posted February 17, 2007 QUOTE(Thang Nguyen @ Feb 15 2007, 07:31 PM) Hi,I am currently working on a project which acquires data from different of devices. They are connected by serial, ethernet communication. I think about the case that in the operation the connection may be disconnected. I am thinking a method to handle this case. I am still new in the industry application so I don't have much experience about this issue. Please give me some idea about sloving this problem. Thank you in advance for your time reading and answering this topic. Thang Nguyen It depends a bit on the connection type. For serial there is not much more than sending a command and waiting for the answer. If that doesn't return anything you can retry once or twice but then you should consider the connection broken and close and reopen it. TCP/IP can give you a connection closed error which you also should handle but that is insofar not enough that a broken network link does not necessary mean that you get this error. So for that you do basically the same as with serial too. Whatever you do you should not just do the classical LabVIEW error cluster handling where you do not do anything anymore once any error occurres. Instead you have to detect errors and actually do some error depending retry or reconnection attempt to get a stable and robust communication. Rolf Kalbermatter Quote Link to comment
Jeff Plotzke Posted February 17, 2007 Report Share Posted February 17, 2007 QUOTE(Thang Nguyen @ Feb 15 2007, 07:31 PM) Hi,I am currently working on a project which acquires data from different of devices. They are connected by serial, ethernet communication. As Rolf said, there's not much you can do for serial other than to see if you get a response back. In the cases I wanted to detect a serial link disconnect, I'd find some sort of "status" command to send to the remote device (some command that didn't do anything other than return data) and send that every second or two. If I didn't hear back a response after a few tries, I considered the device disconnected. So, I'd probably try and find some command that you can send to the devices so you can detect if the device is still connected. Quote Link to comment
Mike Ashe Posted February 19, 2007 Report Share Posted February 19, 2007 QUOTE(Jeff Plotzke @ Feb 16 2007, 09:09 AM) ...I'd find some sort of "status" command to send to the remote device (some command that didn't do anything other than return data) and send that every second or two. If I didn't hear back a response after a few tries, I considered the device disconnected. I do this on TCP Servers, typically calling the command a "heartbeat" if there is no relevant data returned and a "Status_Query" if I expect data from the connection. Standard practice these days seems to be to make a TCP Listener that will spawn off a new instance of a TCP Handler VI for each client that connects in. Each handler sends and receives the TCP messages, usually communicating with other local code via LabVIEW Queues. In my typical implementation I have a flag that can be set, to en/disable the heartbeat functionality, such that the each handler will wait for outgoing messages on the outgoing Queue with a timeout of period=heartbeat. If nothing is available from the Queue, then I send the Heartbeat msg, which expects some trivial reply, "Yep, I'm still here". Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.