Driver Development Kit (DDK)

cancel
Showing results for 
Search instead for 
Did you mean: 

comedi read command and acquire waveforms VIs

I am wondering about the implementation of the comedi read command in the VIs I got from the NI site.

One of the VIs is called "acquire waveforms" which calls "comedi read". everything seems to be working fine, but I am very curious about a small part of the comedi read VI.
If you look closely at it, you will see that after reading in the samples using the CIN that just calls read() , there is a formula node that basically asks the VI to save only the first half of the array. I am wondering why this would be so? Does it have to do with the way read() works?

I tried changing the VI so that the all bytes from the read() call are entered into the "data" array. But when I do this, labview gets stuck.

any ideas?

0 Kudos
Message 1 of 3
(7,110 Views)
Jonny e,
I've seen several sets of VIs to talk to Comedi, but I've only used the ones posted on the NI site:
http://sine.ni.com/apps/we/niepd_web_display.DISPLAY_EPD4?p_guid=B45EACE3ECCB56A4E034080020E74861&p_node=DZ52305&p_submitted=N&p_rank=&p_answer=&p_source=External

To avoid allocating and deallocating memory with the LabVIEW memory manager functions in C, I did all the memory management in VIs. So to receive data back from a CIN call, I would pre-allocate an array in a VI, fill the array in the CIN, then resize the array afterwards in a VI. I think this is what you are seeing.

Tim Ousley
0 Kudos
Message 2 of 3
(7,109 Views)
I'm actually curious about a slightly different part of the VI. (I am using the VI's that you have linked.)

Before the comedi_read CIN is called, an array is initialilzed to be of size "num_samples". The CIN asks for 2*num_samples bytes from the read() call and fills in the already initialized array--which makes sense since each sample returned from comedi is 2 bytes. This array is returned from the CIN. Then just the first half of this array (just returned from the CIN) is returned from the comedi_reliable_read VI. This array is called "data" in the comedi_reliable_read VI.
So what I'm wondering is why take only the first half of this "data" array?
I'm guessing, as you alluded to above, that this is just some memory management happening in labvi
ew.
But I just wanted to make sure there's no way I was leaving half the data behind. I'm almost certain thsi is not the case, since when I input a sine wave, I get a sine wave back.
jon
0 Kudos
Message 3 of 3
(7,110 Views)