LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

restart if end of files

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?

0 Kudos
Message 1 of 9
(3,025 Views)

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?

-----

The best solution is the one you find it by yourself
0 Kudos
Message 2 of 9
(3,016 Views)

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?

0 Kudos
Message 3 of 9
(3,004 Views)

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.

 

 

 

 

 

 

0 Kudos
Message 4 of 9
(2,962 Views)

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.


GCentral
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 5 of 9
(2,950 Views)

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)

0 Kudos
Message 6 of 9
(2,942 Views)

@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.


GCentral
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 7 of 9
(2,934 Views)

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.

0 Kudos
Message 8 of 9
(2,929 Views)

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

 

0 Kudos
Message 9 of 9
(2,881 Views)