LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

getting multiple TCP data

Solved!
Go to solution

Hi folks

 

I configured a VI where I am the listener who reads TCP data, and the server is sending multiple data in a sequential way. meaning that I get one data at a time. My question is, how can I wire each received data to its own destination?

thank you

0 Kudos
Message 1 of 9
(3,083 Views)

Suppose you get 1000 pieces of data.  Do you have 1000 places in your code for it to go?  Most of us want all of the data to go to a single place so that we only have to deal with it once.  Can you explain better the need for each datum having its own destination?

 

Bob Schor

0 Kudos
Message 2 of 9
(3,053 Views)

Hi Bob,

I am getting “Test OK” message from the server. And this data will keep coming for 4 tests performed on a test bench. I want that the first time I receive this, the message is written to its the bookmark of test 1 of a word template, and the 2nd message to test 2’s bookmark... 

 

0 Kudos
Message 3 of 9
(3,052 Views)

If you had attached your code (preferably the entire VI as a VI or a Snippet), as well as the explanation you just gave, we might have understood what you wanted to do.

 

I still don't "see the code", but I'm guessing you have a routine that gets the TCP message.  What it needs is an "associated counter", possibly implemented as an incrementing Shift Register, that can "count" the "Test OK" messages, divide by 4, and use the Remainder to add it to the appropriate Word Template.

 

Bob Schor

0 Kudos
Message 4 of 9
(3,035 Views)

Hi Bob, 

Thank you I think you did understand me. I attached an image to show an example, do you mean that I would just replace the tunnel on my while loop with a shift register?

By the way, the array of strings is the data that needs to go to word template and Test OK is a message for the operator.

0 Kudos
Message 5 of 9
(3,010 Views)

Actually, right now it doesn't matter what tunnel you put on that while loop.  You have a False constant wired to the Stop condition giving you an infinite while loop.  No data ever leaves that loop because the only way to stop it is to hit the Abort button on your VI thus killing all code.

 

Put a For Loop that runs X number of times there.  Create an auto-indexing tunnel and you'll get an array of X number of elements.

 

Now one problem you may still have in your code is how do you know the very first element you read actually belongs to the first test device?  It is very easy for something to get out of synchronization.  Your communication protocol should be robust enough to handle that by having an identifier as to what device is sending the message be a part of the message.

 

Also, use block diagram cleanup.  You have a number of pink wires running underneath that sequence structure making it impossible to know where the data is coming from.

 

0 Kudos
Message 6 of 9
(3,005 Views)

Hi Knight of NI,

Thank you for replying, that one problem I still have is my very first question and topic of this discussion. But I didn't understand what you mean by having an identifier.

0 Kudos
Message 7 of 9
(3,002 Views)
Solution
Accepted by topic author Syrine

If you have each device send a message that is just "1234", how do you know any message came from a specific device?

 

If the device puts in an identifier in its message so device 1 sends "Dev1=1234"  and device 2 sends "Dev2=5678", now you'll know what message belongs to which device!

Message 8 of 9
(2,999 Views)

Thank you Sir!! That really helps.

0 Kudos
Message 9 of 9
(2,985 Views)