LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Good way to initialize clusters and parse files into them

You know,,,....a byte is a byte...why not just format the strings as byte binary in the Type Definition...and then fix them as strings only when they have to be converted for use...

 

??? 

 

Would that work?  What kind of problems do you forsee with that?

 

Hummer1

0 Kudos
Message 11 of 17
(1,000 Views)

The issue with strings is that they can be variable length in LabVIEW, so LabVIEW prepends a length byte when the data is flattened to a string.  I didn't see arrays in your VI (maybe they were in the other VI), but arrays are also variable length and thus have length bytes added in.

 

You can treat the string as a series of U8 bytes, though it might be a pain to define them 63 U8's.  You could define them as a bunch of U64, U32, U16, and U8 to have fewer data elements to define, then later to byte manipulation to convert them to an array of U8's and then to a string.  Go ahead and experiment with that.  I think you'll be able to get it to work.

0 Kudos
Message 12 of 17
(995 Views)

Yes, the input data is an array of bytes (binary file)...as shown in the png image...It was way down in the bottom left hand corner...

 

I'll try the byte/number for string in the type def and let you know how it works out.

 

Thanks.

 

Hummer1

 

0 Kudos
Message 13 of 17
(991 Views)

Okay, if what you have read in is an array of U8 bytes, then use Byte Array to String to convert it to a string.  Then use the Unflatten from String like I showed earlier to turn it into a defined cluster.

0 Kudos
Message 14 of 17
(983 Views)

Ahhh!  That sounds right...let me give that a shot...thanks.

 

Hummer1

0 Kudos
Message 15 of 17
(977 Views)

Nice try, but no joy.  When you convert the cluster as you showed earlier, the boundaries are already identified for the lil-endian...etc.  With the raw bin array, none of that format is known...

 

Guess I'll have to stick with the Russian approach ("Russian components, American components....all made in Taiwan... Armageddon the movie) and just keep hitting it with this big hammer in a sub VI...OH well...would have been nice to find a nice easy way.

 

Thanks.

 

Hummer1

0 Kudos
Message 16 of 17
(971 Views)

Did you set the the constant going into the Unflatten from String to be Little Endian?

 

Post a copy of your binary file.  Rename it to .txt if you need to in order to attach it.  Attach a VI that contains the cluster you are trying to put it into (I'm not sure which of the original VI's you are working with.  Is it Channel Header Info Parse.vi?)  Also, any documentation that details how the file is laid out.

0 Kudos
Message 17 of 17
(963 Views)