LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Stop program at reading binary file

 I read binary file with IQ-samples from USRP (~ 90 Mb, Fs = 400 kHz). Then I demodulate FM-signal, resamle one to 44.1 kHz and listen on sound card. I read binary file by frames (40000 sampes,  Fs = 400 kHz ). Program works correctly. But if I set frame size equal 1e6 samples, program fails. Error 4 occurred at Read from Binary File in Read (LabVIEW: End of file encountered). Please tell me what should be the true condition of the output from the program? The idea is ending music playback does not coincide with the end of reading the binary due to intermediate buffers. Attached is an image model.

 

LV_edit.jpg

0 Kudos
Message 1 of 11
(4,342 Views)

This error you get is because your are trying to read beyond the end of the file.  In the "Advance File Function" there is a VI "Get File Position".  Use this function to build a logic that if the position is less the 1e6 read only those bytes.

 

Michel

0 Kudos
Message 2 of 11
(4,316 Views)

@Michel_Gauvin wrote:

This error you get is because your are trying to read beyond the end of the file.  In the "Advance File Function" there is a VI "Get File Position".  Use this function to build a logic that if the position is less the 1e6 read only those bytes.

 

Michel


Or just clear that spefic error and process it as normal.  Just stop your loop on the error.



There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 3 of 11
(4,305 Views)

Thanks, Michel! But I don't understand why at small sizes program works correctly. The end of file is obtained at any frame size. I compare offset in bytes after current reading cycle with file size. If these values equal, program stops. Why error does take place at big frame size (buffer)?

0 Kudos
Message 4 of 11
(4,304 Views)

crossrulz wrote:

Or just clear that spefic error and process it as normal. Just stop your loop on the error.


Yes, it's a very simple solution. Thanks! But how can I read, process and listen full file? It's time ~58 sec. At big frames error takes place after 15 sec after start reading.

It's my first project in LabView, sorry for the naive questions.

0 Kudos
Message 5 of 11
(4,294 Views)

How do you expect us to troubleshoot code from a microscopic blurry picture???

 

What is the datatype of the samples (i.e. how many bytes/sample)?

 

40000 x 1e6 x (a few bytes/sample) will exceed the range of I32, so you need to make sure to do all calculations involving file positions in I64. As I said, it is impossible to tell what you are doing, but that would be something to keep in mind. Maybe your position rolls over and it keeps restarting to read from a smaller position forever.

 

Please attach your actual VI. Is this 64bit LabVIEW? What do you do with the data once read?

 

0 Kudos
Message 6 of 11
(4,267 Views)

@altenbach wrote:

What is the datatype of the samples (i.e. how many bytes/sample)? 


It's 16bit sample, i.e. 2 bytes/sample (quadratures from USRP). I read file frame by frame. If it very big, I get  Error 4 occurred at Read from Binary File in Read (LabVIEW: End of file encountered).

 

LabView 2013, 32bit.

0 Kudos
Message 7 of 11
(4,262 Views)

SInce you know the byte size and number of samples, it would seem much more reasonable to calculate the total number of reads beforehand and use a FOR loop. No need to constantly check the file position. You can still show the conditional terminal to stop early on error or by the user. 

0 Kudos
Message 8 of 11
(4,247 Views)

Thanks!

0 Kudos
Message 9 of 11
(4,239 Views)

I cheked your solution. For big frame (>1e6) cycle ends earlier than the music. Maybe use queue and task? Cycle for reading binary file and cycle for processing and listening...

0 Kudos
Message 10 of 11
(4,232 Views)