LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Implement my own timeout to abort subVI

I need to abort a subVI without closing the main program after a certain amount of time. I tried dynamically opening the subVI using the "call by reference node" VI, and invoking the method "abort VI" on that VI refnum, but that doesn't work--my program remains stuck in the execution of the subVI. Can anyone help me solve this problem?
0 Kudos
Message 1 of 4
(4,095 Views)
You should not try to use the Abort VI unless you want the entire application to abort. This is annalagous to pressing the stop button in the toolbar. If you want a timeout, then you need to have the subVI monitor its own execution time and not contine whatever loop-driven task you are trying to accomplish.
0 Kudos
Message 2 of 4
(4,095 Views)
Jim is right that aborting a VI is no good programming style.

The "Call by Reference Node" will call a VI the same way as if you have it placed as a subVI on the diagram. If you really see no other chance as aborting you have to do the following: Open a reference to the VI, like you do now. Then set the control values with a "Invoke Node" and Method "Set Control Values". Then let the VI run with the method "Run VI" and "Wait until done" set to FALSE. Now you can start your time out. After time out you can abort the VI.

Waldemar
Waldemar

Using 7.1.1, 8.5.1, 8.6.1, 2009 on XP and RT
Don't forget to give Kudos to good answers and/or questions
Message 3 of 4
(4,095 Views)
Thanks Jim and Waldemar. The subVI I'm trying to make a timeout for is serial port read, and I don't think it's running around in an infinite loop--I think it's freezing when it encounters a problem reading from the port. I tried to follow Waldemar's suggestion, and call the serial port read VI using invoke nodes, but now I've run into more trouble. When I use an invode node to "Run VI", I get "error 1000: the VI is not in a state compatible with this operation". What do I have to change to get the run method to work? I've attached a file that tries to do this with an infinite loop simulating the subVI I'm trying to abort.
Download All
0 Kudos
Message 4 of 4
(4,095 Views)