LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Arrayhandle in a Cluster

Solved!
Go to solution

Hello,

 

I am looking for a way to serialize a cluster which has one or more arrays in it, for example with the Flatten to String function.

 

The problem I am having is that for example my cluster has a uint32 and an uint32 array with only 1 element. When I'am flattening it with the Flatten to String function and then looking into the byte-information I can see that the Array Handle is included in the bytes, even though I am saying not to include the size of the array or the string in my Flatten to String function. Is there any way not to include the Array handle (which is a 4 Byte number including the size of the Array itself = LabVIEW Specifics).

 

I hope the image can make my point clearer.

 

musa__0-1712937169603.png

 

Thanks in advance and feel free to ask if I could make my problem clear.

 

Musa

0 Kudos
Message 1 of 4
(254 Views)
Solution
Accepted by topic author musa_

Hi musa,

 

please read the help for the Flatten function.

The explanation for this behaviour is quite clear: that flag ONLY applies to the top level structure of "anything"!

 


@musa_ wrote:

When I'am flattening it with the Flatten to String function and then looking into the byte-information I can see that the Array Handle is included in the bytes,


This is not an "Array handle", it is the size of each array dimension…

 


@musa_ wrote:

I am looking for a way to serialize a cluster which has one or more arrays in it, for example with the Flatten to String function.


The workaround is to get the cluster elements, concatenate all scalars and arrays into one large 1D array and flatten that array to a string…

Best regards,
GerdW


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

@GerdW wrote:

 


@musa_ wrote:

I am looking for a way to serialize a cluster which has one or more arrays in it, for example with the Flatten to String function.


The workaround is to get the cluster elements, concatenate all scalars and arrays into one large 1D array and flatten that array to a string…


But, are you sure that element is always one character long? If not you will be royally screwed as there is absolutely no way to interpret that "flattened" data later anymore.

If you are absolutely and positively sure that you will always only have one (or another specific number of) character in there, you should actually use an U8, U16, U32, U64 element for that instead. And if you have a non 2^x number of bytes, you should replace it with a cluster with that many U8 in it.

Rolf Kalbermatter
My Blog
0 Kudos
Message 3 of 4
(217 Views)

After flattening the cluster I don't want to interpret the data anymore because in my case I am not working with it after writing it into a file.

 

The main reason I don't want the size of the arrays in the byte data is, because I reconstructed C structures with LabVIEW to read and write into files with that structure. And in C there is no size appended in arrays or strings so this  additional information just destroys my reconstructed C-structure, which I want to work with later on in C for example.

 

My problem now is, how to get that big UINT8 1D-Array with all contents of my cluster. But I guess I will eventually figure it out 😅

 

Thanks,

Musa

0 Kudos
Message 4 of 4
(62 Views)