LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Issue with TDMS file reference stored in FGV. Getting Error 2501

Solved!
Go to solution

Hi,

 

I am not sure what am I missing. I wish to create an FGV that has multiple states (Initialize file, Write, Read Close OR Open, Read, Close). I can initialize a file as expected and it also creates a reference number and an actual file on the disk. But it errors out when attempting to write, read or close file.

 

Only time it works is if I do it all in one go, in linear manner.

Xonmyth_0-1733335715028.png

Edit: Try this sequence Init>Run, Write>Run or Init>Run then Close>Run.



Please see the attached VI.I would appreciate if someone could point out my mistake. LabVIEW 2019 is used.

0 Kudos
Message 1 of 10
(252 Views)

In your VI, you write nothing to the file, you had an empty array added to the shift register. I also got rid of the open state because you already open the file in the int state; in addtion it used the orginal file path, not the one that you checked. See if the attached gives you some clues, as it works for me.

 

 

Message 2 of 10
(218 Views)

Thank you mcduff!

I will double check that.

Can you please save it for previous version 2019? I do not have LabVIEW 21.

Edit: Strange about no values in the array. Since I set some values as default and that is how I could verify that the linear approach worked and the other one with shift registers did not. I left open case for future to directly open a selected file, sorry about the confusion on that.

 

Curious to try your modified VI.

0 Kudos
Message 3 of 10
(215 Views)

mcduff_0-1733348546919.png

 

EDIT: I made a pseudo state machine of your loop for testing, you can change back to a FGV.

 

0 Kudos
Message 4 of 10
(203 Views)

Hi mcduff,

I see what what you pointed out in the "Open" case. Apologies for that, I was skipping over that case when testing but it added confusion. I left it delete untouched now too this time after your modification.

What you gave me works. I changed it to an FGV and it gave error 2501. It is almost seeming like the moment VI stops, something goes wrong with the reference. If I probe reference wire, I can still see the correct reference number created by the first run (init), up until it goes into Write TDMS Vi in the second run (Write) but right after that it becomes 0.

What I did:

1) Select enum to init and run the VI (no error)

2) Select enum to Write and run the VI (Error -2501).

Can you please check one more time to see if this issue gets re-created for you?

0 Kudos
Message 5 of 10
(191 Views)
Solution
Accepted by topic author Xonmyth

Because you are stopping and starting the VI some of the shift registers are going to default values.

 

Try the attached and see if it works for you. The FGV should keep its values while active, once it stops all bets are off.

 

EDIT: Your reference is the problem, LabVIEW closes open references when a VI finishes, so the value doesn't stay on the wire.

Message 6 of 10
(182 Views)

I believe I understand it now. If have a main VI in which this FGV is called (Ran and Stopped but still in the memory), the references will stay alive as long as the main, caller VI is running. 


For some reason this is the first time I am experiencing something like this. Typically, for me values stayed alive even if the FGV was called on its own. But that may have mostly been for simple value (strings, number etc) and not the references. I mostly called those reference based FGVs while their main VI was running but never realized it.

This hurts my brain a little. But thank you so much for patiently bringing me to this point.

0 Kudos
Message 7 of 10
(178 Views)

I think you got it. References can go bad if the Top-Caller goes idle.

Message 8 of 10
(164 Views)

@mcduff wrote:

I think you got it. References can go bad if the Top-Caller goes idle.


Actually CAN is a little weak in this context. It WILL get closed anytime the top level VI, in whose hierarchy that reference was created, goes idle.

Rolf Kalbermatter
My Blog
Message 9 of 10
(113 Views)

@rolfk wrote:

@mcduff wrote:

I think you got it. References can go bad if the Top-Caller goes idle.


Actually CAN is a little weak in this context. It WILL get closed anytime the top level VI, in whose hierarchy that reference was created, goes idle.


True. But I thought if I used stronger language someone would chime in with a static reference example. 🙂

Message 10 of 10
(91 Views)