LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

TCP Communication - How can I remove the priority of which VI will run first?

Hi. I would appreciate for any advise.

I want to communicate (send data) to another PC using wireless radio. I am presently testing the shipped examples;

TCP Communicator Active.vi and  TCP Communicator Passive.vi. I will run first the Passive.vi in the other pc (as

indicated in the instruction) and then Active.vi on this pc.

I want to remove or neglect the priority of which VI will run at first (either of the VI can run first).

If in the case either one of the PC is not transmitting data, it will just trigger a LED or any kind of indicator.

Can anyone helped me to do this? or is there any other example vi that will do it?

 

Thanks a lot.

 

0 Kudos
Message 1 of 14
(3,473 Views)

With TCP Connection you need to create a Listener first, so that the Clients can connect then.

You should think about using UDP Broadcast (see Examples).

 

Christian

0 Kudos
Message 2 of 14
(3,456 Views)

Thank you for your kind reply. I did ran some of the UDP Vi's yesterday and it looks what i am looking for (either of the VI can be run

first).

I have searched on the wikipedia and learned that TCP needs handshaking and very reliable, while UDP it says is not reliableSmiley Sad. Is this true?

http://en.wikipedia.org/wiki/User_Datagram_Protocol

I am new to this protocol thing and i can't decide which is best for my application. Is there any guide for selection?

Thanks a lot.

0 Kudos
Message 3 of 14
(3,436 Views)

Hi Mr Christian,

 

i decided to use TCP/IP for peer to peer communication. I made an example VI of what i am doing but i cant make it right especially on the "Time out error". I would appreciate for any advise.

Kindly see the attached VI's. The Crane 1 will be the Master or Server and Crane 2 and 3 are Slaves or Clients. Slaves VI will pass their data to Master while Master will distribute the data to each VI.

As a rule, i have to run the Master or Server first and Slaves will follow.

But as soon as i do this i am getting this Time Out error hence data are not being passed. I tried changing the values of time out constant but not lucky so far. I know that if i can fix this time out error, all the VI can communicate properly. I should see three moving cranes on each VI.

 

Additional question; If all of the VI are running, and I intentionally Stop for instance Crane 3 (Slave), then it will show an error (LED) that Crane 3 data is not available. So far i can do this.

But for instance I will run again Crane 3 (Slave), is there a way to RESET the connection programatically so that Master VI will once again accept the Crane 3 VI?

 

Any advise I would greatly appreciate.

 

Thanks a lot.

Download All
0 Kudos
Message 4 of 14
(3,363 Views)

I would like to add the sub VI for the earlier message.

 

Thanks.

0 Kudos
Message 5 of 14
(3,362 Views)

When I did the TCP/IP communication for one of my previous projects, what I did was to use the Timeout error on the server (while create listener) to determine the client is not ready/connected. So whenever I received a Timeout error, I would clear the error and just loop back to the create listener again and wait. This way I had no problem getting the connection done.

 

If the time out is occuring while waiting for the data, that just means there is no data to read for that period, all you need to do is to clear the error and wait for data again.

 

Hope that helps !

Cheers !

0 Kudos
Message 6 of 14
(3,347 Views)

Thanks for the reply.

But i still dont get it. Do i need to replace all "TCP Listen" function to "TCP Create Listener" function?

What values should i put on the TCP Read and TCP Write Timeouts?

 How did you do this?

"So whenever I received a Timeout error, I would clear the error and just loop back to the create listener again and wait"

 

Thanks for your help.

0 Kudos
Message 7 of 14
(3,339 Views)

When you use the LabVIEW Example Finder and type "TCP/IP" you will find three VIs named "Multiple Connections - Server.vi" and "...- Client1.vi" and "...- Client2.vi".

I would suggest you to run this VIs, read the information on their frontpanels and blockdiagramms, observe how they work.

Then you can build up your application, or send your data with thoose example.

 

Christian

0 Kudos
Message 8 of 14
(3,335 Views)

Thank you very much for highlighting to me those example VI's. I tried to revise those VI for my application but so far I dont

know where to connect the data I want to pass from the slave VI to the Master VI. I tried different approach though but

cant make it right. 

 

So far if you run the attached VI, Master can pass its data to the Slave but viseversa i cant figure out yet.

 

Any advise would be greatly appreciated.

 

Thanks a lot.

Download All
0 Kudos
Message 9 of 14
(3,311 Views)
You may want to look at the examples in the example finder for TCP Communicator Active,  and Passive.  They show how two way communication is handled.
0 Kudos
Message 10 of 14
(3,309 Views)