LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Reading and Parsing a Binary File

Solved!
Go to solution

I'm having trouble parsing a binary file correctly. I'm using the Labview example 'Read Binary File' I've attached to open the file. I suspect that I'm using the incorrect parameters on the 'read from binary file' command.

 

Here is a little background on my application. The binary file I'm trying to read has data stored as 16-bit and 32-bit unsigned integers. The data comes in chunks of 18 bytes; within this 18 byte chunk are five 16 bit values and two 32 bit values. In the end I'm only concerned with pulling one of the 16 bit values from each data chunk, so its fine if the sorting method interprets the 32 bit values as two consecutive 16 bit values.

 

 

Any suggestions on how to parse the binary file correctly? Thanks for any suggestions!

P.S. I've attached an example of the binary file I'm trying to parse. It didn't have an extension so I chagned it to .txt for uploading. It has 40k+ events, and a 18 byte data chunk is recorded for each 'event', so the binary is fairly long.

Download All
0 Kudos
Message 1 of 5
(4,387 Views)
Solution
Accepted by LittleOwl

You can either read the file as all bytes and do some Unflatten gymnastics, or specify the datatype for Read from Binary file.  No need to feed it the size, just let it read all of the file at once.  Lovely how the snippet crops the cluster constant.

 

 

ParseBinaryFile.png

0 Kudos
Message 2 of 5
(4,380 Views)

Hi,

I wonder if you could help me on this simple issue.

I am quering a Scope with 10k Samples, and expecting to get out 10k Samples on the GUI.

I am using the Example ReadBinaryData.vi and modified it a bit to read out the Data from the Scope.

The Binary File indeed starts with#6100000 but I alwasy getting the ArraySize of 5000, why?

 

Thanks for the info

Y3G

 

Download All
0 Kudos
Message 3 of 5
(4,056 Views)

Hi Y3G,

 

well, you convert 10,000 bytes to 5,000 I16 values. Seems correct to me…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 4 of 5
(4,052 Views)
Please don't hijack an old and unrelated thread.
0 Kudos
Message 5 of 5
(4,037 Views)