02-23-2018 08:24 AM - edited 02-23-2018 08:27 AM
Hi guys
I am using TCP Listen to connect the host pc and my RT target to transmit videostream and some more data. Then, while the RT target is still running, there are times that the host pc is being disconnected to the tcp network. When I run the host pc again, it was unable to receive the videostream and the data that comes from the RT target. I discovered that I need to restart the RT target to reconnect the host pc in the tcp network. However, this takes a lot of time. Is there any way to reconnect the host pc to the RT target again without restarting the RT target?
02-23-2018 08:42 AM - edited 02-23-2018 08:46 AM
What does your RT code do when it loses the connection? You will need to put some error handling/connection recovery code in your RT application to try and re-establish the connection once it is lost. Can you post your code?
02-23-2018 08:45 AM
How is the RT handling the disconnect from the Host?
Are you looking for new connections when a disconnect is detected?
02-23-2018 08:59 AM
Currently, I do not have any error handling code once the host is disconnected. What kind of code shall I create once the host is disconnected? Sorry I do not have any idea since I am just new to coding in Labview. Thank you for all your suggestions
By the way I cannot post the code at the moment since my laptop is not with me. Maybe tomorrow I can post it
02-23-2018 10:13 AM
@jasonrenz wrote:
Currently, I do not have any error handling code once the host is disconnected. What kind of code shall I create once the host is disconnected? Sorry I do not have any idea since I am just new to coding in Labview. Thank you for all your suggestions
By the way I cannot post the code at the moment since my laptop is not with me. Maybe tomorrow I can post it
Without seeing what your RT code architecture looks like, we cant really give you concrete advice, but wherever you are handling the connection, if your read or write functions return an error other than just a timeout(or if you miss a heartbeat, if your setup includes one) I would close the connection, then attempt to reopen. If the reopen fails, wait a short amount of time, then attempt to reopen again - continue this until a valid connection is established.
I would put all this code in its own loop - with some mechanism for passing data received to the rest of your application, and receiving transmission requests from the rest of the application.
02-23-2018 12:14 PM
@paul.r wrote:
I would put all this code in its own loop - with some mechanism for passing data received to the rest of your application, and receiving transmission requests from the rest of the application.
Ditto. I typically have one loop to do nothing but read from the port and pass the data on to whoever needs it. If I get a timeout or error, I close the port and wait for a connection again. A very simple State Machine will do this with no issues. My little trick is I like to store the reference in an Action Engine and let that handle the writing to the port (any other loop can use it to send data to the client).
02-23-2018 10:40 PM
How will the RT target know if the connection of the host PC is lost?
02-23-2018 10:56 PM
The attached file is the code that I am using
02-24-2018 10:05 AM
@jasonrenz wrote:
How will the RT target know if the connection of the host PC is lost?
The simplest way is to use a watchdog setup. The idea is you have a "ping" message you have your PC send to the RT and have the RT reply. This ping should be sent every so often (I use a couple of seconds). So if a read times out, you can assume the connection was lost.