01-22-2007 08:11 AM
01-22-2007 08:25 AM
I just wanted to comment about one thing I noticed right away. You shouldn't use one queue to send commands and data back and forth. If you enqueue some data in the sub vi, but the main vi doesn't dequeue it in time, your sub vi will then dequeue it to see if it's a command. You could lose data the way you're passing it back and forth. I would suggest making a separate queue for commands.
Also, the way you have this setup, you don't even have to call the sub vi dynamically. Just put the sub vi right on the block diagram and it will run exactly how you want it to. It will run in parallel with any other code you have in the main vi that does not depend on it.
01-22-2007 09:39 AM


The support VI needs to be reenterant in order for the "Run VI" method to work" is not true. It's only true because of what you're doing. If you use the "Open VI Reference" function then you do not need to make your subVI reentrant. 01-22-2007 11:28 AM
01-22-2007 12:02 PM
Ok here's what you do. Instead of checking to see if there is something in the queue before dequeueing an element, just use the dequeue. There's a timeout input on it. Set this to 100 ms. Then wire the timed out output to a case structure. The false case will run if there was an element in the queue, the true case will run if it's empty and hasn't received any data. This is probably how you had it running when you said one of the vis hung up, you just didn't have a timeout specified.
Now, if you do it this way, you definitely need 2 queues, becuase this will dequeue an element as soon as there is data available. So if you enqueue a command or data, you don't know which vi will dequeue it. There is a race condition.
As far as calling the vi dynamically, like I said, you don't even need to. Just put a regular call to it in the main vi where you have the Run VI node now. It will start running in parallel with the rest of your code.
01-24-2007 10:30 AM - edited 01-24-2007 10:30 AM
Message Edited by smercurio_fc on 01-24-2007 10:30 AM