Question

I am trying to read in data stored in a custom binary file generated using LabVIEW. The data file is created by writing an array of clusters. I want to read in the cluster information from this data file using a program written in .net. Is there an easy way to do this without modifying the labview generated file?

Was it helpful?

Solution

This depends a bit on your definition of "easy".

If you're using the standard LV functions, a directly written binary file is stored in the same fashion as LV stores data in memory. So, the first 4 bytes store the number of elements in the array. The remainder is the actual data: clusters. Each cluster is composed of its members, each of which has a byte size as specified in the link above. This can get a little obtuse if you have clusters of arrays of clusters of arrays of... anyway, once you figure out the types and sizes of the data that was written, you're halfway there.

Next, you can almost read the file in using a .NET BinaryReader. However, LV was descended from the Mac, and, as such, it's big endian. BinaryReader doesn't do that.

Fortunately, Jon Skeet does. Check his MiscUtil library for an EndianBinaryReader that can read the data in correctly.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top