キャンセル
次の結果を表示 
次の代わりに検索 
もしかして: 

append binary file

解決済み
解決策を見る
I would like to append new binary values to the existing binary file. Write File.vi looks like a good candidate for this, and it has two inputs, pos. mode and pos. offset which looks like something useful for my task. Unfortunately whatever I put into pos offset input I got Error 4 �end of file� and whatever I put into pos. mode nothing changes in binary file. There is also no example on the web which makes any use of them.

Please can you tell how I can simply append new binary values to existing binary file. I put vi. In attachment which will write binary file, but only once.

Thanks,

Zoran
0 件の賞賛
メッセージ1/11
6,503件の閲覧回数
When you open the file you get the file size out from the open function. Wire that number to the pos.offset input of the write function.

The write function has an output that will return the offset after the write so if you need to do more than one write you can use that output as input to the next write (the write will by default start at the current position though so in many cases that's not necessary).

An alternative is to just set the pos.mode to "End".
0 件の賞賛
メッセージ2/11
6,504件の閲覧回数
This is what I tried before and either idea is not working. Write function output always returns zero and pos. mode doesn�t seams to do anything different with �End� or �Start� mode. I put simple vi in attachment where you can see this.

Thanks,

Zoran
0 件の賞賛
メッセージ3/11
6,503件の閲覧回数
It's because you have wired the constant 2 to the file open function, which is create or replace, not open or create (missed that one when I looked at it the first time). Just delete that and right-click on the terminal and select create constant, you then get an enumerated cosnatnt that shows the name of the selected value as well, option 1 is what you want; open or create. Remember also to wire the file size of the open to the pos.offset (skip the control), and you can remove the pos.mode control.
0 件の賞賛
メッセージ4/11
6,503件の閲覧回数
The problem is not with the "write", but with the "open". You open the file with code 2, which Creates/replaces the existing file. (Only you know why this constant is named "open or create" ;-), quite confusing at first. )

You need to open with code 1. Please delete the constant, the right click on the function(open:0) terminal and select "create constant". Now you'll have a nice ring control to select the right mode.
0 件の賞賛
メッセージ5/11
6,503件の閲覧回数
解決策
受理者 zoran
This works! Thanks.

Zoran
0 件の賞賛
メッセージ6/11
6,503件の閲覧回数
Will this work if I have a situation like this ?
 
I have a DAQ VI which gives me about 32667 events in about 10 loops. I want to append these events onto a binary file after every iteration. I followed the message conversations regarding the append binary file but for some reason only the latest set of events are recorded. Will this work in a loop ?
0 件の賞賛
メッセージ7/11
6,258件の閲覧回数

There is actually an example VI that installs with the DAQ driver that illustrates how to append data betwee iterations of a loop during an acquisition. The name of this example is "Cont Acq&Graph Voltage-To File(Binary).vi". The part about fooling with header information can be a bit confusing, so you can cut that part out if it's too complicated.

Kind Regards,

E. Sulzer
Applications Engineer
National Instruments
0 件の賞賛
メッセージ8/11
6,244件の閲覧回数
I exactly did the same thing with Labview 8.0. For some reason it just stores the data from the latest acquisition. Here is how I am doing mine:

Open File -->For loop --> Data acquire --> Get file size --> Set File position --> Write to binary file---> end loop --> close file
0 件の賞賛
メッセージ9/11
6,236件の閲覧回数
Sulzer

I got mine to work. When I get the data from my DAQ I write them to a binary file inside the loop. I keep appending data for as long as I acquire data (using get file size, and set file position).

This seems to work reasonably well.

Thanks
0 件の賞賛
メッセージ10/11
6,215件の閲覧回数