LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Producer/Consumer loops throws error when subtracting timestamps

Solved!
Go to solution

I have a strange error that I suspect is a bug, though I would love to find out otherwise. I'm using to producer/consumer with time-stamped data. In the consumer loop, I would like to be able to zero my data to a new start time, but doing so occasionally triggers an error out of the enqueue element inside the producer loop. Am I missing something here?


Error:

Error 1 occurred at Enqueue Element in Enqueue Error.vi

Possible reason(s):

LabVIEW: (Hex 0x1) An input parameter is invalid. For example if the input is a path, the path might contain a character not allowed by the OS such as ? or @.

I'm running LabView 2024 Q1.

 

Other variations that have given me this error:

- enqueuing time as a double rather than a timestamp

- performing the time stamp subtraction before the data is enqueued

- enqueuing the data into two separate queues - sometimes only one throws an error

Enqueue Error.png

 

0 Kudos
Message 1 of 5
(288 Views)
Solution
Accepted by nail_clippers

Don't have LabVIEW on this computer to test, but an issue I see looking at the code.

 

In your consumer you are flushing the queue; this will occur whether the queue has elements or not. If the queue is empty, then default data values occur and now your times will be less than zero. This triggers a stop, then destroys the queue leading to the error in the producer.

 

Use queue status to check the queue if it has any elements first, if so, then flush, otherwise wait until it has elements.

0 Kudos
Message 2 of 5
(280 Views)

Ah, thank you. That did it. Working code is shown below.


Enqueue Error Resolved.png

0 Kudos
Message 3 of 5
(246 Views)

I would suggest you change your code just a bit more.

 

If your queue has a problem, you could be stuck in an infinite while loop waiting for elements. Some mock ups are shown below:

 

PS: Initialize your Shift Register with an empty array in the bottom loop; otherwise you may have some issues. If your code runs for a long time, your method of storing data is highly inefficient as your memory will resize constantly.

 

mcduff_0-1718658428918.png

 

 

 

0 Kudos
Message 4 of 5
(230 Views)

Good point. In my full program I'll be sure to address the infinite loop and memory management.
Thanks for your help!

0 Kudos
Message 5 of 5
(186 Views)