LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

UDP Bundling values to send?

Hi All,

I'm still tip-toeing my way into learning LabVIEW (currently using LV2017), and looking for assistance with understanding the necessary instructions for bundling values, passing them over UDP and unpacking them.

I've grabbed the UDP Multicast example from NI and that works great, but added a second random DBL value and wanted that to display on the Receiver VI as a result of Unbundling the two values.  

 

The UDP is a Sender/Receiver example that sends a random floating point number and simply plots the value in the Receiver VI.

 

I've scoured the Community and youtube to attempt to find some guidance for how to properly structure multiple values to combine and send over UDP, then receive and unpack the packet on the Receiver end.

I thought this had me on the write course ( https://www.youtube.com/watch?v=kdPyGcJNQbM ), but do I need the cluster as the merge point when I'm simply trying to bundle multiple values and push them across UDP?

 

Should it be: Value 1 & Value 2 ->Bundle->Cluster->(? Proper way to convert this to STRING so it will input into UDP Write ?)

Or is this a more efficient method?


Thank you in advance for any responses!!

PlumPine

0 Kudos
Message 1 of 2
(171 Views)

There is no single magic answer to your question. UDP packets simply need a number of bytes as its data payload. UDP itself doesn't care one way or the other what that data is, what it means or how it should be interpreted. That is the responsibility of the higher level protocol. As long as each side knows what the protocol is then it will know how to interpret the data payload.

 

The protocol should be defined in such a way that it makes sense for the data being transmitted. That is, is the data a series of measurements for the same item? For example, a series of temperature readings from a single sensor. Then using an array would make sense for the data. If the data was a collection of related data, possibly of different data types, a cluster would make sense. In some cases the protocol itself does a very good job of describing the data being transmitted. SNMP is an example of this type of protocol.

 

The important thing is that both sides should know and agree on what the protocol is. For any structure you create such as a cluster make sure you use a typedef so both sides can use the same cluster definition and that if you update the cluster definition all places that use it will also be updated.

 

In terms of flattening the data to a string use the Flatten to String and Unflatten To String VIs. Obviously flatten is used on the transmit side and the Unflatten with the correct data type representing the data is used on the receiving side. So if you bundle your data into a cluster and then flatten it, on the receiving side you would wire the same cluster definition (remember to use a typedef) wired to the Unflatten From String node.



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 2
(156 Views)