LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Read Binary file created from LV13 on LV7, is possible?

Solved!
Go to solution
Highlighted

Hi Guys.

I need to read one binary file created from LV13 on LV7. The LV13 have function READ BINARY and I put the data type (cluster of the four arrays) and the result is ok, but in LV7 this function is completely different.

How do I read this file? Is possible?

See the attachment how reading in LV13.

 

Thanks,

Wendel

0 Kudos
Message 1 of 11
(1,707 Views)
Highlighted

First, please do not post pictures of code -- we can't modify it, test it, see it clearly, etc.  Post the actual VI.

 

Second, to read a Binary File, you need to know exactly what was written to it.  The Binary File represents the data byte-for-byte as it exists in computer memory.  So the number "1" as an I32 is 3 bytes of 0 and 1 byte of 1, while the name number as a Dbl is 8 bytes and might not be easily recognized if you looked at the bytes.

 

The internal representation of common data types (integers, floats, time stamps, booleans, etc.) shouldn't have changed between LabVIEW 7 and LabVIEW 2016 (I have access to both, but I'm currently "on the road", so testing will be difficult).

 

Can you post a small LabVIEW 7 "Binary Data File" and a description of what you think it contains?  Is it a single Cluster of 4 Dbl Arrays?  Do you know the size of the arrays?  Binary Write functions have two options -- the order of the Bytes (the so-called "Endian" issue) and whether or not Arrays are written with their size pre-pended.  If you post an actual data file, I should be able to deduce the correct settings and see if I can read it.

 

Bob Schor

0 Kudos
Message 2 of 11
(1,690 Views)
Highlighted

Wendel, I don't have LV7, but as I remember, binary read function is similar.
If that function doesn't accept cluster as datatype, try this:
read n=I32 (size of 1st array), then n elements of double (or other type of array's elements) and i32 again (size of next array).

read.png


If in write function you don't change byte-order parameter, LV7 will read your VL13 file.

0 Kudos
Message 3 of 11
(1,674 Views)
Highlighted

@Wendelf wrote:

Hi Guys.

I need to read one binary file created from LV13 on LV7. The LV13 have function READ BINARY and I put the data type (cluster of the four arrays) and the result is ok, but in LV7 this function is completely different.

How do I read this file? Is possible?

See the attachment how reading in LV13.

 

Thanks,

Wendel


That picture is as useful to troubleshoot a LabVIEW issue as the image below is to troubleshoot an xml issue.

not helpful.PNG

 

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 4 of 11
(1,617 Views)
Highlighted

So sorry Bob and billko for what happened.

Forgive me for being slow to respond. I worked a lot these days.

 

I am sending VI in LV 13(write binary file) and another with reading binary functions present in LV7.

 

Artem, thanks for your suggestion but have one problem, the size of the arrays are not fixed.

 

Thanks

 

PS.: If possible read the file writed as an example, okay. But if is necessary to change the writed file (eg to put the array size or to use another funciton) there is no problem too.

Download All
0 Kudos
Message 5 of 11
(1,574 Views)
Highlighted

@Wendelf wrote:

Artem, thanks for your suggestion but have one problem, the size of the arrays are not fixed.

 

I know it. This is reason why array size written into file before array values. See prepend array or string size? terminal.

0 Kudos
Message 6 of 11
(1,560 Views)
Highlighted

The Good News is that LabVIEW 2013, by default, writes the Array Size(s) when doing a Binary File Write.  You'll need to "know" (for LabVIEW 7) that the data are saved as a Cluster of 4 Arrays of Dbl.

 

The tricky part comes from reading the data in LabVIEW 7.  There are Binary Read routines, but the two that are present are Read I16 and Read Sgl.  What you need to do is to read the entire file into a 1D array of I16 (I'm having difficulty accessing my LabVIEW 7 system, so I can't give you the details, but the LabVIEW Help should "help").  You then use TypeCast to format the data.

  1. Read entire file as 1D Array of I16.  Get ready to parse.
  2. Remove Array of 2 (I16), TypeCast to a single I32.  This is the Array Size for the first Array of Dbl.
  3. Use Array Size to drive a For Loop.  Inside the loop, remove Array of 4 I16, TypeCast to Dbl, and bring out as Array of Dbl through indexing tunnel.  This is first element of 4-element Cluster.
  4. Repeat Steps 2 and 3 three more times to get remaining three elements of Cluster.
  5. If other data (than the Cluster of Arrays you showed in the LV13 Write code) are present, use methods similar to Steps 2 and 3 to extract them.

Bob Schor

0 Kudos
Message 7 of 11
(1,543 Views)
Highlighted

@Bob_Schor wrote:

  1. Read entire file as 1D Array of I16.  Get ready to parse.

Bob, why you read two i16 and typecast to i32 instead of direct read one i32?

0 Kudos
Message 8 of 11
(1,529 Views)
Highlighted

As near as I can tell, the only "Binary Read" functions in LabVIEW 7.0 are Binary Read I16 and Binary Read Sgl.  I'm currently three time zones away from my PC with LabVIEW 7.0 and am having difficulties connecting to it, so I haven't been able to more carefully study this situation.

 

The ideal, of course, would be to read the file as a U8 array, allowing you to access it on a byte-by-byte fashion.  However, if you have it as an I16 array (and have sufficient memory), you could TypeCast it to a U8 array and thereby gain a convenient access to "all the bytes that fit", and process them as appropriate.

 

Bob Schor

0 Kudos
Message 9 of 11
(1,506 Views)
Highlighted
Solution
Accepted by topic author Wendelf

Well, you say Write is for LV13 and read is for LV7 but the VIs in your post are actually both in LV15 saved!!

 

The file IO functions have been quite a bit revamped in LV 8.0 but they didn't remove anything nor added a lot to it other than the ability to select the Endianess on the Binary Read and Write.

In LabVIEW < 8.0 you didn't have seperate nodes for the Binary and ASCII string modes but they were really all combined in the same node. Still you could read and write binary data there too, and the flattened format for all the basic datatypes didn't change at all. So to read the file that you created in your Write binary file LV13.vi in LV 7 you would need the attached VI. Any other binary read and write should work the same. This works for all integers (except 64 bit which don't exist in LabVIEW before 8.0), single, double and extended precision floats, complex types of the floats, booleans, strings, clusters containing any of these and arrays of any of these types and even the timestamp should work in LabVIEW 7 too.

 

Where it could get tricky is if you try to write Variants, Analog and Digital Waveforms, and other such LabVIEW special datatypes. Their internal binary data format isn't really documented and at least some of them have changed between LV 7 and later versions.

 

Note: if you open this VI in a LabVIEW version 8.0 or later LabVIEW will mutate it to use the new file IO nodes. So to see how it needs to be done in LabVIEW 7 you really will have to open it in LabVIEW 7.x.

Read Binary File LV7.png

Rolf Kalbermatter
Averna BV
Message 10 of 11
(1,479 Views)