08-11-2009 04:35 PM
I write a binary file in LV8.6 of an array of clusters in which each cluster has many data types in it including more arrays and clusters. I want to read this data in a MatLab program but nothing is reading correctly. It also seems like there was change between after labview 7.x where the type defs were written in 16 bit before are now in 32 bit. and I can't find any documentation on how the binary write function stores data for complex data types. Any search for documentation on the labview website just brings up hundreds of irrelevant hits. I try to read the binary file in matlab and i don't see any of the expected numbers coming out.
Anyone have a link to where i can get the specs for LV >= 8.6 binary formats. Or the full info on flatten-to-string for the newer versions of labview.
thanks.
Solved! Go to Solution.
08-12-2009 05:03 AM
Maybe this KB helps:
Christian
08-12-2009 05:13 AM
08-12-2009 09:52 AM
evren wrote:It also seems like there was change between after labview 7.x where the type defs were written in 16 bit before are now in 32 bit.
I have no idea what this means. A typedef isn't written out anywhere. A typedef is just a definition of a structure.
Your most likely problem is that of endianness (Matlab uses little endian, LabVIEW uses big endian), or that you are not taking into account that when you write out an array the default is to prepend the array size before writing out the array.
08-12-2009 11:14 AM
this is all part of the question. does labview write the type def out so that anyone can read it - meaning the structure of the original array of clusters can be recreated without knowing the data type. Obviously the size of an array has to be written before the array data. In what format is the size written? Is it a 16 bit or a 32 bit unsigned int? Is it something else? The first 16 bits i read in the file comes out 0000 in hex. But the array of clusters i saved is not zero in length. If I read 32 bit uints then the numbers get crazy after the first two blocks.
i am reading in big endian in matlab. as far as i know LV writes in big endian by default I have not changed that default in the write program.
thanks.
08-12-2009 12:32 PM
The format of the flattened data is documented in the LabVIEW Help. From the Contents tab expand Fundamentals -> How LabVIEW Stores Data in Memory -> Concepts -> Flattened Data.
The Flatten to String function only saves the data, not the structure. You must be thinking of the Type Descriptors. Yes, this changed in LabVIEW 8. In LV 7 they were 16-bit. In LV 8 they're 32-bit. This is also documented in the LabVIEW Help. Fundamentals -> How LabVIEW Stores Data in Memory -> Concepts -> Type Descriptors.