LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

VI doesn't stop when both while loops are stopped

Hi everybody,

I wrote a TCP/IP where I have a while loop within another while loop. Both while loops are connected to the same stop buttom (the inner while loop is connected to the local variable of the stop button). But when I press the stop button the VI doesn't stop automatically (the "abort execution" button in the upper left isn't pressed automatically).
Does anybody has an idea why?
I would like to have my TCP/IP VI stopped automatically when I press the stop button...

Thanks in advance for any hints...
Steffi
0 Kudos
Message 1 of 5
(4,261 Views)
Hi Steffi,

can you post your VI?  If you run it in highlighted execution mode, is there a sub-VI or process that is hung up?
Jim

LV 2020
0 Kudos
Message 2 of 5
(4,255 Views)
Hi Jim,

how can I run it in highlighted execution mode? With that yellow bulb?
Please have a look at my attached VI.

Thank you very much for your help.

Steffi
0 Kudos
Message 3 of 5
(4,243 Views)
Hi Steffi,

Yes, the lightbulb puts the VI in highlighted execution mode, and you will be able to watch the VI execute.  I suspect that your VI is hung at the TCP listen.  Change the timeout to something less than forever, like 100ms.
Jim

LV 2020
0 Kudos
Message 4 of 5
(4,236 Views)
I am assuming you have two loops to allow the server to restart and listen again in case the connection is closed. Otherwise, the outer loop is pointless.

The answer is: race condition/dataflow. When you first run the loop the Stop button is read by the outer loop. It's False. The VI then sits in the TCP Listen function. Once the connection is received you go inside the inner loop. It chugs along, and you decide to press the Stop button. This is read by the local variable, and causes the inner loop to stop. This does not cause the outer loop to stop since the stop terminal for the outer loop has already received its value from when the loop was first run. Thus, it runs again. On this second run it reads the Stop button and this time it's True. However, since the VI is sitting in the TCP Listen it won't stop until the VI gets into the inner loop a second time and then gets out (which it will do after one iteration since the Stop button is True).

You need to place the Stop button terminal in the inner loop and tunnel out its value to the outer loop. Get rid of the local variable.
0 Kudos
Message 5 of 5
(4,210 Views)