LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Another LV how to do question

My device sends a bunch of binary data in a chunk. The data is a mixture of
fields of varying lengths and types (32bits numbers, bytes, doubles) based
on a structure defined in a C header file.

Now what's the easiest way for me to parse this data in LV? In CVI, I just
include the header file in my code and typecast the memory block (receivd
from device) to this structure and I got all fields with the values that I
want.

A similar situation would be when you need to pass a structure to/from LV to
C.


vishi
0 Kudos
Message 1 of 5
(2,969 Views)
What you have is referred to in Labview as a "cluster", a grouping of unrelated data types. There are numerous cluster tools in the Cluster toolbox. Depending on the number of dimensions of each data type, you might actually have an Array of Clusters, or a cluster of Arrays. LV can handle both cases with aplomb. The "Unbundle by Name" is probably your best bet, to start with, assuming your data is in contiguous arrays. If you would like to send me a sample data file, I'll show you how this can be "wired".

Good Luck!

Chutla
Eric P. Nichols
P.O. Box 56235
North Pole, AK 99705
0 Kudos
Message 2 of 5
(2,968 Views)
I think maybe my question wasn't clear. I know about cluster. My question is
how LV stores elements in the cluster. If I make a cluster in LV based on a
strcuture in C, that all fields will be properly aligned?

I am worried about the structure packing. I don't see any equivalent to
"pragma" directives in LV. How do I control it so I can pass data from LV to
C and vice versa. I hope it's not the way VB works while dealing with C
data.


vishi

"chutla" wrote in message
news:506500000005000000C4EA0000-1042324653000@exchange.ni.com...
> What you have is referred to in Labview as a "cluster", a grouping of
> unrelated data types. There are numerous cluster tools in the Cluster
> toolbox. Depending on the number of dimensions of each data type
, you
> might actually have an Array of Clusters, or a cluster of Arrays. LV
> can handle both cases with aplomb. The "Unbundle by Name" is probably
> your best bet, to start with, assuming your data is in contiguous
> arrays. If you would like to send me a sample data file, I'll show
> you how this can be "wired".
>
> Good Luck!
>
> Chutla
0 Kudos
Message 3 of 5
(2,968 Views)
Hello again!

The size of your data fields is unimportant in Labview as long as your delimiters are defined. If there is a problem, you can also explicitly parse the data, using "format from String", which is exactly equivalent to "scanf" in C++ or Matlab. I think you'll find Labview very forgiving in this regard, as it can be either a strongly typed or weakly typed language. You can also typecast any data if necessary, or coerce it into a fixed form.
Eric P. Nichols
P.O. Box 56235
North Pole, AK 99705
0 Kudos
Message 4 of 5
(2,968 Views)
> I think maybe my question wasn't clear. I know about cluster. My question is
> how LV stores elements in the cluster. If I make a cluster in LV based on a
> strcuture in C, that all fields will be properly aligned?
>
> I am worried about the structure packing. I don't see any equivalent to
> "pragma" directives in LV. How do I control it so I can pass data from LV to
> C and vice versa. I hope it's not the way VB works while dealing with C
> data.
>

LV alignment in clusters does match a common setting for C compilers,
but LV itself doesn't support much in the way of pragmas. Some of the
nodes have a popup to turn on 4.x format data compatibility or a similar
choice for compatibility with older LV alignment or data formats.

The Extern
al Code documentation will tell you the detailed pragmas that
LV expects a DLL to be compiled with in order to be compatible with LV.
Basically, the LV setting is byte aligned, no alignment.

If things get hairy, it may be easiest to pass the individual elements
into a wraper DLL and build the structure there, but this isn't normally
necessary.

Greg McKaskle
0 Kudos
Message 5 of 5
(2,968 Views)