LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how can i convert string data from UDP Read to Cluster of U16 U8 U16 and U16[] using unflatten from string

Hello all

 

I need to read incoming data using UDP and then convert read UDP_string data to Typedef Cluster of U16 U8 U16 and U16[]. i tried using Unflatten from string pallete to wire type def cluster to Type terminal and then wire UDP Read string to binary string and passing "true" constant to terminal "Data Includes Array". I am getting error 74. Not sure what could be the reason for this error. Please help me with a best way to deal with this.

0 Kudos
Message 1 of 12
(2,654 Views)

Hi Vive,

 


@VivekaSheregar wrote:

i tried using Unflatten from string pallete to wire type def cluster to Type terminal and then wire UDP Read string to binary string and passing "true" constant to terminal "Data Includes Array". I am getting error 74.


So you create a VI, which is not working. And you need help to improve this VI.

But you hesitate to attach that VI? How should we improve it then?

 

When you attach your VI: don't forget to include some useful default data in your "UDP read string" indicator!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 12
(2,643 Views)

I see a couple of possible issues:

1. Your type def cluster does not match what is being sent

2. The sent data does not include the array size in the flattened data

 

We definitely need some example data to proceed any further.  If you have the sender code as well, that would be helpful.


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 3 of 12
(2,627 Views)

From your description it sounds like you shouldn't use "Data includes Array" as i assume it indicates that it'd mean an array of said cluster. But i might be wrong.

/Y

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 4 of 12
(2,613 Views)

@Yamaeda wrote:

From your description it sounds like you shouldn't use "Data includes Array" as i assume it indicates that it'd mean an array of said cluster. But i might be wrong.


The actual input is "Data Includes Array Or String Size".  But regardless, if you have an array or string inside of a cluster, that input is ignored and it is assumed the sizes are in the data.  It kind of has to otherwise you don't know where the next element in the cluster begins.  Do note that the same rules applies to the Flatten Into String.


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
Message 5 of 12
(2,605 Views)

Aside from attaching your VI, who wrote that data? Another LabVIEW program of some other software? How did it write it? You have any description of the format or can show the relevant code.

It's in all cases doable but the correct answer depends on the answers to these questions. If it was not written by LabVIEW you may need to have to split the parsing into multiple Unflatten functions to get it working.

Rolf Kalbermatter
My Blog
0 Kudos
Message 6 of 12
(2,595 Views)

Here is the attached screenshot of a vi.. 

0 Kudos
Message 7 of 12
(2,574 Views)

Please attach actual VI as requested, and not a picture of a VI.

 

Problems I think I see from the picture.

 

1.  You unflatten from string and say the data has the array size, but your raw data does not have the bytes that would indicate the array size.

2.  You wire a U16 to your case structure, but the selector consists of 4 bytes and not 2.

Message 8 of 12
(2,556 Views)

@RavensFan wrote:

2.  You wire a U16 to your case structure, but the selector consists of 4 bytes and not 2.


So we assume the Message ID is actually an U32.  That still makes the U16 message length 0x0085 = 133 (bytes? samples?).  We are nowhere close to reaching that length.  The rest would make sense though since there are 6 bytes left for, I assume based on the constant display, 3 U16 values.

 

So we are back to these questions:

1. Where did this data come from?

2. What is the EXACT protocol for the data?


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 9 of 12
(2,548 Views)

This data is coming from the Unit Under Test which has code written in C. I am not really sure if C code uses flatten to string method to transmit UDP Packets.

 

I am trying to figure out the best way to parse this data.

Instead of using split string pallet and String to Byte Array Function, i want to follow Unflatten from String method. Please suggest the best method.

0 Kudos
Message 10 of 12
(2,528 Views)