LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

"Error 1 when trying to open and read datalog file from several subVi's

So, I've been coding up this model based controller and have hit a snag:
The program starts and opens a datalog file and passes the refnum to two loops.

At a regular time interval (every 2 minutes), one loop (that's iterating once per second) writes the current information to a datalog file.

Meanwhile, another loop (that's iterating continuously) checks to see if the file is big enough to support training of the model, if it is, then the training process begins. Once this happens a period of recent information is read from the file. Initially, this read would fail and return 0 data. However, this problem was fixed by passing in the data file path rather then the refnum and having the vi open,
read, and close the data file. With the path, the vi was able to read all the data. However, still in the same loop, another vi downstream tries to read the file and returns error code 1, and no data is read. I tried passing that vi the path and seeing if it made any difference to open, read and close the file. But even then the read failed (with error code 1).

I don't understand why it can read in one vi and not the other!

Does anyone know what is going on here? It seems that semaphores would probably solve the problem, but would prefer a simpler solution. Thank you very much.
0 Kudos
Message 1 of 2
(2,567 Views)
Try passing the data to the continuous loop through a LV2-style global. That way you are only access the file in one place. But then that begs the question, if the data is passed internally, do you really need the file at all?

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 2 of 2
(2,567 Views)