From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
09-09-2020 12:07 PM
Hi.
Long story short: I have a SubVI (CoG.vi) based on the NI QMH template and at some point the Dequeue Message.vi in the processing loop is blocking while having its Timeout input wired to 50ms without generating any errors. I spent hours trying to understand what can cause it, and surely I'm missing something dumb but I can't figure it out...
It's very tricky to share any any code as I would end up sharing almost the whole project for it to work, but here is a summary of my problem:
Here is the general idea:
- When called, CoG.vi inits Control, UI and Platform queues and starts the different loops.
- The trigger loop sends the message "Update Attitude" in the Control Queue.
- Control Loop dequeues it and send a message with an appropriate command into Main WifiComms Queue and "awaits" an answer from Platform Queue (Timeout of 0 ms, will read next iteration if empty at the execution)
- Main.vi dequeues this message, process the command and then sends back appropriate data over the Platform Queue (via a data management loop)
- CoG.vi receives this data and process it accordingly.
All of this goes fine and you can see it in the following screenshot:
The CoG.vi
The main.vi comms loop:
Now, whenever I click on the Lasers Button for instance, for some reason the Dequeue Message.vi in the Control Loop will block. It won't generate an error (I know, I don't have any error management yet, but I checked) it won't timeout. In debug mode I can see the green arrow showing that it is executing.
After clicking on the emergency button, this one sends a command directly to the Main WifiComms Queue (not the control queue) which, for some reasons, suddenly unblock the Dequeue Message.vi in Control Loop and starts dequeuing all element in the queue.
I have thought of various possibilities causing this:
I really don't get it...
Am I missing something obvious you could help me with or is it something more complex I need to dig in?
I'd like to point out that while not a complete beginner, I am lacking experience 🙂
Thanks a lot in advance for any help.
Vinny.
Solved! Go to Solution.
09-09-2020 12:43 PM
09-09-2020 12:53 PM
Wire up a "Get Queue Status" (and wire true to the return elements input) and look at the number of elements in the queue.
Saying "Thanks that fixed it" or "Thanks that answers my question" and not giving a Kudo or Marked Solution, is like telling your waiter they did a great job and not leaving a tip. Please, tip your waiters.
09-09-2020 12:55 PM
Yes I did add the timeout myself. I needed it somwhere else.
And actually I finally found my issue, and it is a very dumb mistake ...
So I wanted my UI loop to execute only when there is something to process ... So put the dequeue message timeout to -1. Turned out as long as nothing was asking to update the UI, the Dequeue Message exection was stuck in there and it is non-reentrant .....
I am ashamed, but I can finally go home.
If it can save someone's afternoon: if you introduce a timeout to your dequeue function, remember to either never put it to -1 or to execute as reentrant...
Thanks anyway greg for taking the time.
09-09-2020 01:05 PM
@VinnyAstro wrote:
If it can save someone's afternoon: if you introduce a timeout to your dequeue function, remember to either never put it to -1 or to execute as reentrant...
Slight correction here: It should ALWAYS be set to be reentrant. Any VI that does a Dequeue and possibly some parsing to the received message needs to be reentrant, regardless of the timeout. I go so far as to make them inlined in most cases.
09-09-2020 03:45 PM
Yep well I learned the hard way...
As for the parsing I do that in another loop to free as fast as possible the wifi communication (which I need to benchmark because my comms loop gets saturated with only 3 commands every 500ms, that's not normal, either the wifi.vi or the queue is slowing down)