LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

TCP Communication response

I have a 2 state machines that are connected through user events.  One of these is for taking measurements and writing data, the other is to control loading, moving and unloading the UUTs this is done through TCP communication (this is defined already from the vendor so I cant change that).  With the the load there is a long wait time until I have a response over TCP and I dont want to have the measurement machine locked until I have a response.  I would assume the best way would be just to ping the TCP read in a timeout loop with the TCP read timeout set to 100ms and clear the error until there is a response.  This should give me the ability to response to other user events and keep the machine active.  

 

Again maybe I am on the right path for this and it is the best solution but something tells me there is a better option that I am not seeing.

Anyone have a better solution?

0 Kudos
Message 1 of 3
(2,363 Views)

If your communications with the device take some time I would consider creating a separate task that is solely used for communication with the device. Uses messages to instruct this task for what actions need to be done. For example, your main state machine would send a message to the task to initialize the device. The response for this may take quite some time. The communication task will be waiting for the response in parallel to your main state machine which is free to perform other tasks. When the device finally replies, the communication task will receive the data (do some parsing or processing if necessary) and send a message to the main state machine which can now act on that message. The communication task can also send error messages such as a timeout when the response was never received. This type of architecture is very flexible and powerful. The Actor Framework is a messaged based system and its actors run in parallel. That could be a good place to start. It can also be done without using AF but it does provide many of the pieces you will need.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 2 of 3
(2,339 Views)

It would be nice if you can add code snippet or screenshot. much quick solution possible!

0 Kudos
Message 3 of 3
(2,286 Views)