LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to do UDP from two sources?

My client has an instrument which communicates via TCP for command and control, but sends data samples via UDP to the host computer.

The machine can be configured to communicate to port X, via some sort of keypad interface (probably with an umpteen-level menu system).

There is a factory default value for X.

So I open a UDP socket on port X, and read data from it, all is well.

Now the client wants the ability to have TWO of these machines attached (occasionally - the second one won't be permanent).

I could tell them to configure the instrument to send on port X+10, then I could open a second socket on port X+10, and read from it - I'm pretty sure that would work.

--- BUT ---

That would mean that when they borrow the primary instrument from one test cell to use as the 2nd machine in another, they have to re-configure it.

Is there a way to avoid that?

Looking at the UDP Read function, there is a PORT output (the sending port) and an ADDRESS output (the sending address).

If both instruments are sending to the same PORT on the host, can I use a single UDP READ to listen for data, and use the ADDRESS output to determine where it came from?

Will I get a batch from machine 1 (address 1), then a batch from machine 2 (address 2), or is the data going to be jumbled and mixed together?

If I could separate it cleanly, then they wouldn't have to re-configure the machine when they moved it. But I don't know enough about UDP to answer this, and I don't have even one of these ($$$$$) machines to test, let alone two.
Steve Bird
Culverson Software - Elegant software that is a pleasure to use.
Culverson.com


Blog for (mostly LabVIEW) programmers: Tips And Tricks

0 Kudos
Message 1 of 2
(2,242 Views)
UDP is a packaged connectionless protocol. This means the sender sends it to a IP adress and port and forgets it. The reader will see a package coming from a IP adress and port. The sequence of the packages is undetermined so a package send later can be received earlier than the previous package. This could happen when routers are involved in the transfer and packages are taking different routes with a different numbers of routers. If you are within one local network this would not happen.

The reader will see each package and the UDP read will tell you where it is coming from. You have to distinguish the two data streams not by the ports (the can be the same) but by the IP adress. The sequence of the packages is unpredictable if the two machines are not synchronized.

A package from machine A will not be mixed up with a package from machine B.

Message Edited by waldemar.hersacher on 06-14-2005 10:00 PM

Waldemar

Using 7.1.1, 8.5.1, 8.6.1, 2009 on XP and RT
Don't forget to give Kudos to good answers and/or questions
Message 2 of 2
(2,231 Views)