LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Read binary file in chunks

Hi everyone:
 
 Smiley Happy I'm working on a program which reads binary file in chunks. The problem is all data points read out in the last chunk are zero. The program and a few binary files are attached. Any help will be highly appreciated!Smiley Happy
PS: Why should I divide 4 instead of 32 (because my data type is I32) to calculate the number of counts and offset to make things work? I cannot understand this although it seems correct. Smiley Sad
 
best
Camu
0 Kudos
Message 1 of 3
(3,553 Views)
You divide by 4 since you have to talk in terms of bytes, not bits. I32 = 4 bytes.

The problem with the code is the way you're reshaping the 2D array output from your for-loop. You need to reshape based on the dimensions of the array. In other words, you need to do this:

Note that the value is the same as the loop count times the chunk size.

Some other comments:
  • The sequence structure is not necessary. I know you're trying to set up a comparison situation here, but you can wire the first Read from Binary File directly in the stream without any loss in functionality, and you get rid of a sequence structure.
  • In the for-loop you have a Set File Position because the initial Read from Binary File would have placed you at the end of the file. However, you do not need to set the file position each time in the loop. You only need to set the file position back to the beginning, and you can do this once outside the loop. Each iteration of the for-loop will read the file from where it left off.
  • Likewise, the Set File Position after the for-loop is not necessary.
  • Instead of negating the output of the Equal? function, how about simply using the Not Equal? function? Smiley Very Happy
  • If an error occurs you will not know it since you are not wiring out the error cluster or have an error handling dialog. This occurs when you run the code on a system where the "automatic error handling" is turned off (like mine).


Message Edited by smercurio_fc on 07-16-2008 04:42 PM
Message 2 of 3
(3,540 Views)
Oh.. Smiley Happy All the questions are answered in a really clear way. Thank you a lot, smercurio. I really appreciate this help.
Smiley Happy
Best
Camu
0 Kudos
Message 3 of 3
(3,531 Views)