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.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Enqueue/dequeue problem

Solved!
Go to solution

hello guys,

i've come up with a problem which needs ur expert guidence and reviews.lemme try to explain my issue with you.so that you might get a better understanding and guide me ahead.

i have a client VI which controls a power supply PST-3202 serially.i read power supply  current,voltage values and then make a packet of it which i further transmit to another VI (say server) after every second running on the same PC using TCP write.

my server can handle multiple clients .so what it does, it receives data using tcp read function successfully. and i can see that received data on tcp read using string indicator.till here everything is working fine problem lies ahead.

problem point:

now what i do further, i take data from tcp read and enqueue this data in  the same tcp read's while loop and then dequeue it in another while loop.where it is being written in a text file and after some data manipulations it is being sent  using TCP write in third while loop to database server  which is running on some other PC.

now my problem is my power supply data is received successfully at above mentioned tcp read in first while loop.similarly my connection with data base server remain estabilished successfully.

and both VIs work fine for 7 hours but suddenly what happens after 7 hours of contineous running of VIs is ,the data enqueued successfully in first while loop but  dont gets dequeued neither got written in text file in 2nd while loop,and the while loop where dequeuing is taking place stops working.where as system remain intact with data base server and power supply client.

means problem appearantly liea in enqueue/dequeue process.and last but not the least when this enqueue/dequeue process stops working my server VI also gets hangged and when i press the stop button it doesn't stop  the VI from running and i have to close the VI by force using task manager end process.

now i need ur kind suggestion to tackle this problem.what should be the strategy to cop this issue.please guide

Best Regards

PS: if anyone wants  to see my VI,i can show that as well.

0 Kudos
Message 1 of 17
(2,937 Views)

You've probably got an error handling issue or memory leak somewhere, but no one is going to be able to really help you beyond guessing without seeing the code. Zip up the whole project, including all three of the main vis and any required subvis and upload.

0 Kudos
Message 2 of 17
(2,928 Views)

@hassan2019 wrote:

 

PS: if anyone wants  to see my VI,i can show that as well.


It is usually a good idea to go ahead and include your code when you post originally. It is difficult to see what you've done wrong without actually seeing what you've done wrong.

 

With that in mind, my guess is that your processing loop is taking too much time and you're getting a backlog of data in the queue. This could be exacerbated by the file size getting larger if you're not managing file size.

0 Kudos
Message 3 of 17
(2,924 Views)

ok i will share my VIs with you guys on monday

till then can u please elaborate what do you mean by memory leak? and how to solve this memory leak issue if it really exist in the code

0 Kudos
Message 4 of 17
(2,844 Views)

thanks john for ur kind response.i will share my code on monday.

but i want to know is it possible that data can be backlog in the queue? and i am using a simple text file to write my data.do i still need to manage file size of a simple text file.if yes? then how to manage it please give some valueable suggestions.

 

0 Kudos
Message 5 of 17
(2,841 Views)

@hassan2019 wrote:

thanks john for ur kind response.i will share my code on monday.

but i want to know is it possible that data can be backlog in the queue? and i am using a simple text file to write my data.do i still need to manage file size of a simple text file.if yes? then how to manage it please give some valueable suggestions.

 



I’ve made the assumption that you did not change the default queue size. If you’re not, on average, taking data off of the queue as fast as you’re putting it on the queue then the queue will begin to build a backlog. 

I don’t know how you’re managing your file. Are you opening and closing the file on every iteration, for instance. These are the kinds of things that we will be able to see in your code. 

0 Kudos
Message 6 of 17
(2,829 Views)

hello.

here is my attached VI but its in labview 12 so please pardon me in advance.

now i need ur valueable help.

regards

0 Kudos
Message 7 of 17
(2,784 Views)

hello Mr paul and Mr john i need ur kind guidence .plz have a look at my VI

0 Kudos
Message 8 of 17
(2,777 Views)

Hi hassan,

 

why do you need to create and kill queues with each iteration of your loops?

Why do you need to kill a queue reference in parallel to still accessing the queue? (That's called race condition!)

Why do you need to open file references in a loop without ever closing them?

 

Please examine the example VIs to learn the handling of queue/file references…

 

Why are there two (2) hidden TCP reference arrays on your frontpanel, both named "empty"? Why do you need them and why don't you replace them by constants in the block diagram?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 9 of 17
(2,755 Views)

i would really appreciate if you give me a hint about handling of queues ans files. no doubt u raised valids points but u must give me some alternate solutions.

as far as tcp reference is concerned that is the requirement of my programs.u may ignore it

but  for queues and file handling i need ur kind suggestions

thanks

0 Kudos
Message 10 of 17
(2,733 Views)