‎03-15-2015 03:22 AM
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.
‎03-15-2015 07:13 AM
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
‎03-15-2015 07:57 AM
@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.
‎03-15-2015 07:58 AM
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)?
‎03-15-2015 08:08 AM - edited ‎03-15-2015 08:08 AM
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.
‎03-15-2015 11:53 AM
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?
‎03-15-2015 12:07 PM - edited ‎03-15-2015 12:08 PM
@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.
‎03-15-2015 12:32 PM
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.
‎03-15-2015 12:46 PM
Thanks!
‎03-15-2015 01:36 PM
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...