06-04-2014 02:44 AM
hello,
I'm reading a binary file with LabVIEW. However, I would like to start again at the biginning when the EOF is reached. How can I implement this?
06-04-2014 03:00 AM
You can set the marker to start in the Set file position function before feeding the reference to the read from Binary file. Is that what you are looking for?
06-04-2014 03:29 AM
How big is the file and how often does it change?
Would it be sufficient to read it once into memory then scan through it repeatedly?
06-06-2014 05:25 AM
Thanks you all for your reply. The hint of Knight seems more interessting although it will be limited to medium files size. In my case the file is actually around 170M (can be bigger if I record over a long time or a wider frequenzband) and muss be read as often as possible. My VI is attached to this post. When running the code it actually executes properly then afte some itteration it lost synchronisation and you heart some Zuzzzzz and the program stop because of error occurance. The question is how to make restart more efficient and seemless. Or how mitigate the effect of pointer deplacement in file.
06-06-2014 07:46 AM
You need to clear the error before you set the pointer. Most LabVIEW functions don't do anything if they see an error coming in.
Still, it seems to me that you should just read the entire file at the beginning and then you just keep it in memory.
06-06-2014 08:05 AM
thanks crossrulz, you might be right! but how do I save 10Gb data in memory? still I don't know how to perform this operation with labview (storing and accessing data in memory)
06-06-2014 09:38 AM
@Aristocrate wrote:
thanks crossrulz, you might be right! but how do I save 10Gb data in memory? still I don't know how to perform this operation with labview (storing and accessing data in memory)
Ok, you didn't say anything about 10GB. That's a big jump from 170MB you said earlier.
What I do when checking for the end of a file is unbundle the error cluster and compare the code to 7. If equal, you get the end of the file, so set the pointer back to 0. I also clear the error only if I find error code 7. If there is some other error, I need to know.
06-06-2014 10:03 AM
Since it is a binary file, you can calculate the file offset for each datasegment with basic math (make sure to use 64bit integers!). Simply use "quotient and reminder" and divide by the file size, then use the remainder to set the file position.
06-11-2014 08:30 AM
Hallo alenbach,
your solution works; however, there is still error or unexpected behavior.
for instance I get memory overflow after running the VI a few minutes. Actually I've used CDL data types. That is, 8 Bytes is been used to save a sample. I read 2541 samples pro fecht (20328Bytes or 160kbits). after a while I got memory overflow.
The second problem is certainly a simpling rates isssue. since its output at a higher frequence at it has been saved.
Do you know how I can handle this?
Thanks