LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Reading a growing binary file

Hello,

I have an application that is writing binary data to a file. Using LV, I need to open and read this file in,
update the chart, and continually update the chart as long as the data is new. The data is 8 byte
little endian format. The problem I am having right now is, after opening the file, which may have been
written to for an hour already, I need to fully update the chart with all the data, then continue to read the
file, looking for changed size, at a rate in the loop which will not hog out the processor. Is it possible to
accomplish both of these objecives in the same control loop, that is:

1 - Read in all the data from the file (after opening), and update the chart at the quickest time possible
2 - Continue to update the chart at a controlled rate (i.e., 50ms to 100ms loop time) until the user
selects stop.

Stuck on this one! Any help would be much appreciated!

Thanks, Gary.


0 Kudos
Message 1 of 4
(2,874 Views)

Hi Gary,


Are you trying to write and read from the file at the same time? Is it possible for you to post your code or post a snapshot code so we can better understand as to what’s going on?

Adnan Zafar
Certified LabVIEW Architect
Coleman Technologies
0 Kudos
Message 2 of 4
(2,857 Views)
Gary,

Look at the Advanced File functions. Get File Size and Get/Set File Position may allow you to do what you want fairly conveniently.

The big thing to watch is the time to open and close the file by the write and read programs and to avoid data corruption. Some of this may be limited by the OS.

Lynn
0 Kudos
Message 3 of 4
(2,849 Views)
Thanks for your reply!

Yes, the file is being written to. So...

1 - A user launches a separate program which creates and is appending a file.
2 - At some time point, the user then opens this program. This program must open the
data file being written to, and plot all the existing data up to that point, and continue to follow/read the new data
and plot that.

Here's a jpg pix of what I have. The data is of type double. I have utilized an existing example of queues
fom the NI examples.
This potential solution was recommended although I'n not sure it is the right way to go. Problems now:

When there's no valid data, the graph is updated with "0.00" (not good)

Not sure if setting the file count to -1 (on Read Binary file.vi) is OK. If I use "Get File Size.vi" , in the while loop,
it grabs the initial size, but the first value plotted is the last data in the file. (I know this because it is a time stamp)





0 Kudos
Message 4 of 4
(2,846 Views)