LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Advanced File I/O Techniques

Hi,

 

I built a Binary File writer vi and a Binary File reader vi but I can't get the file reader to read from the writer file. I get error message each time. I've attached both VIs and I will appreciate any inputs. Thanks

 

 

Download All
0 Kudos
Message 1 of 8
(3,560 Views)

What error message do you get?  What error number?  That kind of information would help.Smiley Wink

 

I see a couple problems with your Binary writer VI.

 

1.  The big one.  Why do you wire the array size to the Input of the writer which tells whether it is big endian or little endian?

 

2.  There is an input for prepend array or string size which you did not wire. By default it is true.  Try making that False.

0 Kudos
Message 2 of 8
(3,556 Views)

Ravens Fan 

 

I made the changes you suggested but I still get the same error message. Here is the error message I got when I ran the file reader: 

 

Error 4 occurred at Read from Binary File in Binary File Reader.vi.  Possible reason(s):

LabVIEW:  End of file encountered.
=========================
NI-488:  Invalid argument or arguments to function call.

 

0 Kudos
Message 3 of 8
(3,543 Views)
On the Read From Binary File vi, you have it set to "replace or create".  You want it set to "open".  If it's "replace or create", it will delete the file and there won't be anything to read.  So the end of file will be encountered immediately.
-Matt Bradley

************ kudos always appreciated, but only when deserved **************************




Message 4 of 8
(3,533 Views)

Hey Mbdeck,

First, Check your operation enum on your open/create/replace file, you are telling it to replace or create the file, eliminating the data that was there before. Try 'open' instead.

Second, you are only writing one item to the binary file, an array. If you use an array constant as the input to the data type on the read from binary file and set the number of data points to '1,'  you do not get the error. Your output will become a cluster of arrays, but it displays the same, and you can unbundle if truly necessary.

-Mello

 

PS looks like I crossed time with Matt above... 

 

Message Edited by Mellobuck on 06-10-2009 03:34 PM

Data Science Automation

CTA, CLA, CLED
SHAZAM!
0 Kudos
Message 5 of 8
(3,531 Views)

Beat you be 2 minutes Mellobuck! 

🙂

-Matt Bradley

************ kudos always appreciated, but only when deserved **************************




0 Kudos
Message 6 of 8
(3,526 Views)

Your read VI destroys your data. Wire "Open" to the Open/Create/Replace VI instead of "replace or create". While writing set "prepend array or string size?" to FALSE.

 

If you set "prepend array or string size?" to TRUE while writing your data you need to read an array at once. In this case wire a real array to "data type" of the Read from Binary File VI.

 

There is a difference in reading "Number of data Points" times a single real and reading an array of reals with "Number of data points".  Sounds stupid? Replace in mind array by cluster than you will see the difference.

 

Regards

Jörn

0 Kudos
Message 7 of 8
(3,525 Views)
I was even slower.
0 Kudos
Message 8 of 8
(3,523 Views)