Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

how to read all buffer content in RT FIFO applications

Solved!
Go to solution

Hi;

In my application, I would like to read all buffer content (which is made up of a series of 1D array) all at once and then empty the buffer so that the upcoming data can be written to the buffer in the next step in my code. I am wondering if there is anyone out there who knows how to do this.  

Thank you very much.

Serdar 

0 Kudos
Message 1 of 6
(5,374 Views)

Hi Serdar,

 

You cannot read all of the data at once. With a FIFO, elements are written to and read from the buffer one at a time. One thing you can do is place the RT FIFO Read in a loop. Each time you read from the buffer check the output of the element # terminal to see how many elements are left in the buffer. When that that value reaches zero, exit the loop and continue on to write more data to the buffer.

0 Kudos
Message 2 of 6
(5,356 Views)

Thank you Olivia for your response. I really appreciate it. I can empty my buffer using a loop as you suggested. However, in my application, values keep being written to the FIFO  as the FIFO content is being read in the loop. Therefore,  my buffer will never become empty resulting in the loop running forever. ( Unless I read buffer way faster than I write, which is not be the case.) Do you have any suggestings for this problem?

I found the smart buffer example in LabVIEW which does exactly what I want. However, the smart buffer was designed for scalar entries, and as a result, is not applicable to my implementation in which I need to buffer arrays. Do you know how to make that code work with arrays? (I posted this question in another stream but haven't received any answer yet.)

Thank you so much for your help!

Serdar 

0 Kudos
Message 3 of 6
(5,350 Views)

Hi Serdar,

 

You won't able to use the Smart Buffer example with 1D arrays. The reason for that is the "buffer" created by the functional global is an array and mades use of 1D array properties. Since your elements are arrays, this will not work.

0 Kudos
Message 4 of 6
(5,330 Views)
Solution
Accepted by topic author SERDARSOYLU

Hi Olivia

 

It is possible! The only thing you need to do is to pack the 1D array in a cluster and add that to a 1D array of clusters in the buffer.

So in practise it is a bit more work bu doable.

 

step 1 replace the internal 1D array by a 1D array of cluster of 1D array. (sounds difficult, just do it)

 step 2 replace the float by a 1D array and as a first step bunde that into a cluster.

step 3 replace the output by a 1D array and retrieve that from the buffer and unbundle immediately before wiring to the indicator.

greetings from the Netherlands
Message 5 of 6
(5,316 Views)
I think this is a really neat solution. Thank you so much for this solution. 
0 Kudos
Message 6 of 6
(5,294 Views)