01-22-2018 11:38 AM
hii,
I have to read data from the bus which I do get as Bytes.
But I want to parse the Information. Ist easy if ist Bytes and words as I have built Cluster for that.
How to build a Cluster with a nibble and 2 bit data all together eg (8bit, 8bit, 4bit, 2bit)
The Minimum value for a constant is 8 bit .If there is a Cluster ist gonna be str. type def and can be used Overall.
yes there are other methods to parse but I prefer to implement Clusters.
any Workarounds here.
regards,
Akshay
01-22-2018 11:43 AM
I have no idea what you are talking about.
How is the cluster supposed to look like? (type of elements, number of elements, etc.)
Can you attach a simple VI showing a typical input and how the result should look like?
01-22-2018 12:25 PM - edited 01-22-2018 12:26 PM
Someone has the document that describes the data structure. If it's not you, then you'd better obtain it. Once you have it, share it with us.
Some hints: It's okay to represent that numbers that are smaller than a byte as a U8 - as long as you remember that you need to encode it properly - if you ever need to do that. If these numbers represent choices, you can use a text ring or an enum to limit the user only to valid values. (Each method has its own pros and cons; choose wisely, Grasshopper!) e.g., for a 2 bit number, use a U8 text ring or enum that only allows choosing 0, 1, 2, or 3. This works especially well for encoding. (You then need to fit that into 2 bits, but most of the work is already done for you.) It gives the user a context for the numbers, and it saves you the headache of needing to handle invalid values.
01-22-2018 12:55 PM
Well, a computer works off of Bytes, not anything less. So just store your smaller data as a U8 as previously suggested. It is simple enough to perform masks and bit shifts to the received data.
01-23-2018 02:56 AM
a word of thanks to all responders.
yes I did not clarify the method.
I am basically trying to typecast the Input data(frames) , which are chunks of 8 Bytes each into a cluster.
But in the System we use 2 Bytes , 1 Byte, a nibble,2 bit or 1 bit data to represent the state of the DuT.
as I and many of you mentioned there are other methods but typecasting with a Cluster is simple because I can save the Cluster as strict type and use it elsewhere.
The issue is labview 2013 does not allow a "data type" to be represented as a nibble or 2 bit data. It could have been very helpfull
the png tries to Show the same
regards
Akshay
01-23-2018 04:39 AM
There is no datatype with less than 8 bits, so typecasting will not help you here. If you want to split fractional bytes into individual U8 values, you need to mask and shift. Just create an inlined subVI that converts your array to the desired cluster. It's not difficult.
01-23-2018 07:13 AM
@altenbach wrote:
There is no datatype with less than 8 bits, so typecasting will not help you here. If you want to split fractional bytes into individual U8 values, you need to mask and shift. Just create an inlined subVI that converts your array to the desired cluster. It's not difficult.
I'm terrible at masking, so I actually break them out as individual bits and deal with them that way. It's less efficient code-wise, but for my personal efficiency it's not.
01-23-2018 08:54 AM
Are you working on a Windows, RT or FPGA target?
Only on FPGA can you actually define datatypes smaller than 8 bit. But there is no typecast on FPGA, so I suppose that doesn't really help either.
Do masking and shifting or Byte to Boolean Array and index out the sub-arrays you need to parse them to U8. Create coverter VIs for both directions and you should be fine.
01-23-2018 09:08 AM
thank you all for your Support
I am working on a normal PC no specific H/W.
yes the normal methods , I will be implementing using those.
regards
Akshay