Eugen Graf Posted May 31, 2007 Report Share Posted May 31, 2007 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 Quote Link to comment
gb119 Posted May 31, 2007 Report Share Posted May 31, 2007 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. Quote Link to comment
Eugen Graf Posted May 31, 2007 Author Report Share Posted May 31, 2007 QUOTE(Gavin Burnell @ May 30 2007, 10:22 PM) 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. I have to parse any data. The transmition-protocol is ready defined. http://forums.lavag.org/index.php?act=attach&type=post&id=5970 So I made me typedefs for every package type. This one is the status package. http://forums.lavag.org/index.php?act=attach&type=post&id=5971 My unflatten.vi should parse this package. http://forums.lavag.org/index.php?act=attach&type=post&id=5972 Thank for your answer. I don't really know if I can use here Variant.llb. And I have LV 8.0. Eugen Quote Link to comment
gb119 Posted May 31, 2007 Report Share Posted May 31, 2007 QUOTE(Eugen Graf @ May 30 2007, 09:38 PM) I have to parse any data. The transmition-protocol is ready defined. [...] 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 Quote Link to comment
Eugen Graf Posted May 31, 2007 Author Report Share Posted May 31, 2007 QUOTE(Eugen Graf @ May 30 2007, 08:35 PM) ... a workaround with Cluster->Array or are there another ways to solve it? ... 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 Quote Link to comment
Eugen Graf Posted June 1, 2007 Author Report Share Posted June 1, 2007 Ok, my solution is following. More ideas? Eugen Quote Link to comment
Mellroth Posted June 1, 2007 Report Share Posted June 1, 2007 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 Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.