08-09-2018 02:37 PM
I am currently using a PXI chassis for the first time and I am currently attempting to share data between a DAQmx task created for my PXIe-4300 module, and a thread I've made that does some simple calculations.
Currently, I've got some code to create and configure the PXIe-4300 task that will simply read 3 channels. Once that task starts, I use the DAQmxReadAnalogF64(); DAQmx function to store the daq's buffer data into an array (static float64 array[totalDataPoints]).
I'm also using DefineThreadSafeArrayVar(); to create a pointer that I can set it's values equal to the array[totalDataPoints] mentioned above. Then, in my "calculations" thread, I'm creating the same pointer and attempting to store it's value in a local variable array (float64 threadArray[totalDataPoints]).
When I read the array in the task thread, it looks like everything is working smoothly. However, when I read the array within the calculations thread, I do not read any values.
I guess my main questions are: (1) Am I going about the right approach in order to share information between a task and a thread, and I just need to figure out/fix a few things in my code? or, (2) Is there a better method/approach that I should consider using in order to achieve my goal?
For reference, attached are just a few screenshots of the calculation thread and task callback that is reading all the data.
Thanks,
Alex
08-10-2018
07:32 PM
- last edited on
11-18-2024
04:40 PM
by
Content Cleaner
Hi !
Did you try the examples that are on the web page: http://www.ni.com/example/6999/en/
08-10-2018 07:40 PM
While these are very useful and serve as my current guidance, I've looked through several of these examples and had a difficult time finding one that would specific move an array of multiple channels worth of data across to another thread.
With that being said, it looks like I was able to accomplish what I want with the thread safe queue architecture in LabWindows. I would still be curious to see if there are better/alternative methods, and why I can't read the thread local variable created with DefineThreadSafeArrayVar in one of my threads, but can clearly see it functioning in another. Nonetheless, I've somewhat got things working. Thank you for the response.