LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

error when Write/read Cluster in binary file.

hi all,

I implemented a code (using the Labview example) to save and read cluster data (see attached file). The write part works properly but when I want to read the file, there is an error : "Error 4 occurred at Read from Binary File in main_save_data_V2.vi; LabVIEW: End of file encountered'.
BUT the data are correctly open. Why is there such message? any suggestions?

thank you.

Cedric

0 Kudos
Message 1 of 6
(4,493 Views)

Did you check the size of the file? Can you please post the vi in 2009?

-----

The best solution is the one you find it by yourself
0 Kudos
Message 2 of 6
(4,487 Views)

Plese post an image of the read code.

 

Error 4 EOF is normal when you read past the end of the file. If reading in a loop you toss the last value read when you get the error 4.

 

What eveidence do you have that the file is written correctly?

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 3 of 6
(4,483 Views)

here is the file for Labview 2009.

 

Cedric

0 Kudos
Message 4 of 6
(4,482 Views)

Hi,

 

the problem seems to be the number of objects you tell the read binary vi to read. If I hardwire a constant of 1 to that input the error is no longer encountered. Read the help on the read binary vi - especially the part about that input.

You seem to think that one cluster of the type you are saving should be 8 bytes in size - since it contains arrays it may not even be possible to predict the size unless you KNOW how big those arrays always are.

If you knew that you always wanted to read a fixed amount of clusters you could work with that information.

 

Regards

Florian

0 Kudos
Message 5 of 6
(4,472 Views)

Instead of predicting how many clusters to read, just set the count in the binary read to -1.  That will read all that it can and I got no error.  Here is all you need in order to read the file.


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
Message 6 of 6
(4,459 Views)