LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

reading binary file

Hi!
I'm trying to read data from a binary file. Labview reads the bytes in
the wrong order, e.g. Labview reads the integer '0100' as '256' instead
of '1'. With integer types this is not a problem, but I don't know how
to read doubles or singles and get the right number.

Can anyone help me?

thanks
0 Kudos
Message 1 of 2
(2,872 Views)
ec wrote:

> Hi!
> I'm trying to read data from a binary file. Labview reads the bytes in
> the wrong order, e.g. Labview reads the integer '0100' as '256' instead
> of '1'. With integer types this is not a problem, but I don't know how
> to read doubles or singles and get the right number.
>
> Can anyone help me?
>
> thanks

Labview uses Big-Endian format (most significant byte MSB first).
On the PC the format is Little-Endian (LSB first).
In order to read a binary file created by something other than labview
you will need to use the "Swap Bytes" and / or "Swap Words" functions
Found in Functions->Advanced->Data Manipulation.

for the above example LV reads '0100', send to swap bytes
it becomes '0001', now the integer is correct '1'.
For larger datatypes I belie
ve that you must also use the "Swap Words"
Be aware that if you change the data and write it back to a file you must
swap again before the write if another application will read the file.
Kevin Kent
0 Kudos
Message 2 of 2
(2,872 Views)