LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how to make a binary write/read of a cluster

Hi
 
I am designing a motor control system, which is supposed to save data after each motor run.
 
The data should in the end be located in a spreadsheet together with some additional data processing, but in order to save processing time between single runs, I would like to save data to a binary file, and the proces all data when all my test runs have been executed.
 
My problem is that I get an error when i try to read the file again. I Always recieves error code 4 and I dont reciecve any data
 
I have enclosed an example, which illustrates my problem.
 
I have tried with and without "flatten to string"
 
Kind regards
Bo Vestergård Jensen
Denmark

Message Edited by BoVJ on 02-27-2006 06:29 AM

0 Kudos
Message 1 of 3
(3,035 Views)

Hi,

At first glance, I see exactly what is wrong.  I had the same thing happen to me when I started using the new LV 8.0 file I/O functions. After you get done writting all of your data to file, you must call the "Set File Position" VI to set the read pointer back to the start of the file.

The file write and read pointers always point to the same location, so in your code you start writting data to file and LV is updating the read/write pointer to be at the end of the file.  Then when you went to read the data, the read pointer was already at the end of the file, hence the EOF error and no data. This is why you must call the "set file position" VI to move the read pointer back to the start of the file.

Given that, you can stop using the flatten string functions and just write your cluster to file. This will clean up your read and write operations. I have attached a modified version of your VI.

-Jared

Message Edited by JaredW on 02-27-2006 11:07 AM

0 Kudos
Message 2 of 3
(3,013 Views)

AHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH Smiley Happy

Thank you very much Jared. You just saved me a lot trouble. 

It looked so simple in the help files describing the method for reading binary files... except the problem with the @#¤€&½øåæ#£*€ file Pointer.

Have a nice day.

Bo Vestergård Jensen

Denmark

 

 

 

0 Kudos
Message 3 of 3
(2,992 Views)