Jump to content

Monitor the connection status


Recommended Posts

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

Link to comment

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

Link to comment

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.

Link to comment

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".

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.