LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to parse UDP byte stream ?

Hello,

 I receive binary sensor data from different sensors via UDP (Header + Data (e.g. 4 byte uint) + End). I can read the data as a string (I used the UDP Receiver.vi example), but what is an efficient way to parse the data und to view the data on an indicator ?

cheers, Tobias
0 Kudos
Message 1 of 9
(4,927 Views)
Hi Tobias,

when the data string has a fixed length it should be easiest to TypeCast into a properly defined cluster!
Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 2 of 9
(4,924 Views)
Hi,

thank you for the fast answer. Unfortunately the message size is not fixed, but the size is contained in the header (byte 3), which has a fixed size. how can i parse this ?

Regards, Tobias
0 Kudos
Message 3 of 9
(4,904 Views)
Solved 🙂
0 Kudos
Message 4 of 9
(4,895 Views)

Hi, I am new to Labview and am trying to do exactly this. Would it be possible to you to generate a simple example of "TypeCast into a properly defined cluster"? Thanks Joe

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

@joe5213 wrote:

Hi, I am new to Labview and am trying to do exactly this. Would it be possible to you to generate a simple example of "TypeCast into a properly defined cluster"? Thanks Joe


The second Type Cast is the example you are looking for.  The first one was just to make some the string in the first place.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 6 of 9
(3,883 Views)

Hello, I have used the example UDP Receive.vi to read UPD packets from another computer. I have wired the output of the UDP Read into a String to Byte Array to verify that I am receiving the correct UPD data words. The UDP data is the same for every packet. I've read in another post that because the data length is the same then it would be simple to use TypeCasting. I am having trouble and need some help. I have created my Cluster and it has the order of the data that is in the packet. Some words are 14-bits wide and other are of various bit-width. Can anyone help me get the TypeCasting to work? The problem is when I try to connect the Cluster to the TypeCast's type input.

 

Thank you very much,

joe

0 Kudos
Message 7 of 9
(3,864 Views)

Do you actually have a 14-bit wide word?  If so, you have a very abnormal data structure.  Most words are 16 bits wide.  And when you say others are various widths, exactly what widths?

 

There is no way we can help you solve your typecasting unless you attach a sample of the data string you receive, what the results should be, and also some description of the protocol that decodes it into different values.  If you truly have data elements that are bit-packed in a way such as a 14-bit word, then typecasting won't help you and you'll have to parse it down to a bit level to piece together all the data.  If you do have data elements that consist of one or more whole bytes, then typecast probably will work.

 

But as I said in the other thread, you should really start your own new thread rather than tacking on to a six year old thread.

0 Kudos
Message 8 of 9
(3,852 Views)

Thanks. I will look a the data widths again and also post a new post.

 

joe

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