06-09-2009 05:04 AM
Hi,
I intend to use NIDAQmx driver for PCI-6251 card in Linux environment for a multithreaded application. That is, I want to Process buffer 1 while transmitting/receiving buffer 2 and so on. I just installed Nidaqmx driver and found that example programs don't quite do that.
Could someone suggest how to implement the aforesaid functionality ?.
Malik
06-09-2009 05:42 AM
06-09-2009 11:25 PM
Hi,
Thanks for the reply. I am developing an application on Linux using NIDAQmx in which I send a buffer via analog output channel 0 and at the same time receive the same buffer at AI I/P channel 0 (both the analog output and analog input tasks are synchronised and I use only two channels). Once I receive the buffer I process that and then go back in a while loop to transmit & receive the next buffer. So the structure is like this:
While (for iteration 'i')
{
transmit(Buffer i);
receive (Buffer i);
process (Buffer i);
}
The processing of buffer i takes a finite time so I want to implement a parallel functionality such that while 'transmitting and receiving Buffer i', I could also process buffer i-1. In this way I intend to keep on acquiring data without any delay while also outputting processed data without any delay. Since the time to process a buffer is less than the time to transmit/acquire the buffer, I think the while structure as shown in the NiDAQmx examples is not right for this and we may need to implement the data acquisition and processing as separate threads.
Malik
06-10-2009 07:22 AM
06-10-2009 10:16 PM
06-11-2009 07:22 PM
Regards,
Glenn
Applications Engineer
National Instruments
06-12-2009 05:02 AM
Hi Glenn,
Thanks for the reply. Is it possible if you could post the underlying C-code (that uses NIDAQmx driver API functions) to perform the same producer/consumer design pattern ?.
cheers,
Adeel
06-15-2009 03:11 PM
Hello Adeel,
The Producer/Consumer loop we provide in LabVIEW utlizes the same layout as c programmers using semaphores and multiple threads. Just include the DAQmx API in the following code I found online utilizing multithreads. A simple web search of "producer consumer c" populated the following links.
http://procrastinationrising.com/pthread-producer-consumer-example-in-c/
http://www.cs.arizona.edu/~greg/mpdbook/programs/pc.sems.c
-Glenn