Jump to content

Flatten/Unflatten boolean cluster


Recommended Posts

Hello, I would parse a boolean cluster but get some problems(Look attachment). Should I realy make a workaround with Cluster->Array or are there another ways to solve it?

I want also interpret a boolean element as a boolean(=1 Bit) not as a Byte.

Thank you, Eugen

Link to comment

QUOTE(Eugen Graf @ May 30 2007, 07:35 PM)

Hello, I would parse a boolean cluster but get some problems(Look attachment). Should I realy make a workaround with Cluster->Array or are there another ways to solve it?

I want also interpret a boolean element as a boolean(=1 Bit) not as a Byte.

Thank you, Eugen

Flatten to string essentially gives you a straight memory dump of the data with (for versions < 8.0 by default and optionally for >=8.0) a separate ouptut that can describe the structure of the data. Sometime around LabVIEW 4.x/5.x the in-memory storage of a boolean was changed from one bit to one byte, so when you flatten a cluster of 8 booleans you do indeed get 8 bytes back. I'd hazard a guess that the change was done because RAM wasn't quite so critical and memory alignment issues were more so, so it made sense to reserve a whole byte even though only the lsb is used.

I'm not entirely sure I understand what you are trying to do, but if you have 8.2.x or perhaps 8.x, then in the Utility folder of your vi.lib there will be a VariantDataType.llb which has subvis for interpreting variant data-types without getting your hands dirty looking at the flattened data.

Link to comment

QUOTE(Eugen Graf @ May 30 2007, 09:38 PM)

[...]

QUOTE(Eugen Graf @ May 30 2007, 09:38 PM)

Thank for your answer. I don't really know if I can use here Variant.llb. And I have
LV
8.0.

Eugen

So it looks like your data originates from outside LabVIEW - in which case I'm afraid there is no easy way - you need to convert your data to an array of unsigned ints (looks like your protocol aligns on 2 byte boundaries, so U16 will work) and with the individual elements. You can quite easily do U16->array booleans->cast to your type def.

Here's an example of a U8 cast to an 8 element cluster of booleans.

http://forums.lavag.org/index.php?act=attach&type=post&id=5973

Link to comment

QUOTE(Eugen Graf @ May 30 2007, 08:35 PM)

QUOTE(Gavin Burnell @ May 30 2007, 11:15 PM)

...

You can quite easily do U16->array booleans->cast to your type def.

Here's an example of a U8 cast to an 8 element cluster of booleans.

...

I really assumed it.

Eugen

Link to comment

QUOTE(Gavin Burnell @ May 30 2007, 10:22 PM)

...Sometime around LabVIEW 4.x/5.x the in-memory storage of a boolean was changed from one bit to one byte, so when you flatten a cluster of 8 booleans you do indeed get 8 bytes back. I'd hazard a guess that the change was done because RAM wasn't quite so critical and memory alignment issues were more so, so it made sense to reserve a whole byte even though only the lsb is used...

If I remember correctly, LabVIEW (<5.0) used different representations for scalars and arrays.

A boolean array was stored with each boolean as a bit, but boolean scalars were stored as I16 (U16?) values.

/J

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.