LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Error 1 at Get File Size

Hi all,

 

Having some problems with this error and hope you can help. If required I will post pictures of the code, but due to security limitations I would need to blank out certain parts that refer to what I am working on...

 

Anyway, a brief description of the program...

 

I have a main application (main.vi). This application logs information to a log file (will explain this more in a mo). The main application also has a button that opens a subVI as a separate window. This subVI window also has the ability to log data to the same file.

 

So the data logging works by calling a single VI (write2log.vi). This VI then checks if it is the first call to the application, if so it creates a new log file (CreateLogFile,vi) and stores the reference in an FGV (SetGetLogReference,vi). If not it retrieves the reference from that same FGV. Next the write2log file then pulls a "File Size Limit" value from a config file (well, actually from another FGV that has previously pulled it from a config file), it takes this value and checks that the current log file is less in size by using the Get File Size function. If the log is less in size then it just writes the data to the log, if it's greater in size then it closes the current reference and createa a new log (CreateLogFile.vi) before finally writing the data to the log.

 

So that's how the system is supposed to work, the idea is I only ever need to call a single VI to write to a log and don't need to worry about initiating it or anything. The problem I encounter is as follows:

 

The application writes data to the log from main.vi. It also writes data to the log from the separate log window. The problem appears to occur when the log reaches it's maximum file size and has to create a new log file. If this happens when in the main.vi file, then it carries on running fine. If the new log is created when you are logging data from the separate log window, it will carry on working, but only until you close that window and return to the main application, at which point it will flash up with this error. I have probed the reference wire going to the Get File Size function and the reference doesn't change when it errors out, so I'm having a hard time understanding how the reference is fine one moment when called from the Log Window but then no longer valid when called from the main application?? What is also interesting is that the main application is still logging data when the Log Window is open, so it's something connected to closing this window that is causing a problem....

 

Any ideas???

 

Thanks for taking the time to read this,

 

Olly

0 Kudos
Message 1 of 20
(2,969 Views)

Hi Olly,

 

error 1 mainly refers to an invalid (file) reference.

As long as you don't provide your VIs you will have to search for the problem on your own…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 2 of 20
(2,958 Views)

Are you closing the file as part of the shutdown of that second VI?


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 3 of 20
(2,940 Views)

Yup need to see the code.  One other time I've seen this error is when you open a reference then wire it to a For loop without shift registers.  And then pass the reference out of the for loop with autoindexing off.  If your for loop runs 0 times, which happens when you wire an empty array to it, the output reference will be the default of 0.  To fix this use a shift register

0 Kudos
Message 4 of 20
(2,927 Views)

Hi Guys,

 

Thanks for the replies. I'll try and get some code together this morning to upload (Just need to spend some time removing company project info from it first).

 

But in response to your replies:

 

GerdW,

Yep it would appear to be something to do with the file reference, but what I don't understand is that when I am probing the input to that function, a reference is being provided... (the same reference that worked on the previous iterations). Something to do with me switching between the main application and subVI is causing that reference to become invalid, but when I am probing it I see absolutely no change.

 

Crossrulz,

Yes there is a file close in there. However that is only being invoked when the file size limit is reached. It closes the old file reference and creates a new one. After reading your reply last night it did make me wonder if maybe it was some sort of race condition occuring. So this morning I came in and disabled the file close just to check, but the behaviour is exactly the same.

 

Hooovahh,

I do something similar using the FGV to store the file ref, but with a while loop and not a for loop which will always execute exactly 1 time.

 

 

Thanks for the help guys. I'll try and get some code together and reproduce the problem for you guys to see.

 

Olly

0 Kudos
Message 5 of 20
(2,893 Views)

Hi Olly,

 

but what I don't understand is that when I am probing the input to that function, a reference is being provided... (the same reference that worked on the previous iterations)

Easy explanation: the value of the reference will not change, when you keep it in a shift register (or anywhere else). But when you close that reference somewhere else in your code it becomes invalid - even when you still see the same hex value in the probe window…

A reference being "invalid" does NOT mean it has a value of zero!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 6 of 20
(2,884 Views)

Fair point, didn't think of it like that...

 

Anyway, I got rid of the file close and the bug is still there...So if the reference is being closed, I'm not knowingly doing it...

 

I've managed to put together a cut down version of the code, just need to get it checked and approved before uploading.

 

Hopefully will happen in the next half hour...

0 Kudos
Message 7 of 20
(2,877 Views)

Hi Olly,

 

I would prefer LV2011 version, so please do a "save for previous"…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 8 of 20
(2,875 Views)

Files attached (LV2014 & 2011)

 

Thanks again, hopefully i'm just making a silly mistake somewhere...

 

Olly

Download All
0 Kudos
Message 9 of 20
(2,866 Views)

Hi Olly,

 

as a general suggestion I would include all file reference handling inside the FGV!

In the "Get" state you should check current file size and close the old ref and create a new one if needed.

 

You should encapsulate this functionality in one VI - much easier to debug afterwards…

 

Btw. your CreateLogRef should look like this:

check.png

(Well, you should include that part in the FGV as well…)

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 10 of 20
(2,854 Views)