10-18-2022 07:41 AM
Hello,
I was designing a custom DLL for device connectivity and acquiring data from it at a high rate of speed. I was able to retrieve chunks of data at a rate of 60k samples per second.
There is one dll function for initiating the connection, one for collecting and passing the specified number of data samples, and one for closing the connection.
I intend to add a Ring buffer technique to this program.
Now the acquisition stops when I export the data to labview and starts when the DLL function is called again by a loop or some other mechanism.
I want to construct two functions operating simultaneously, one to collect and save data into a specific buffer, and the other to retrieve a specified amount of data to LabVIEW from the same buffer, without impacting or pausing the collection process.
I am new at dll development and CPP programming.
If someone can provide a suitable way to meet this need, it will be of great help to me.
Thank you very much!
10-18-2022 08:05 AM
You will most likely want to create a thread in your DLL that is then passed control of the background acquisition. Look at CreateThread(). But this isn't beginners programming at all. You will have to write a function that does your whole thread handling, basically a loop that keeps looping until you somehow signal it to quit. And you need to communicate with this thread function with thread safe mechanisms such as events and any information you want to access from within that thread as well as your main control functions will need to be protected with semaphores unless you know for sure that access to it is atomic (a single read or write of an integer is usually atomic, a read-modify-write cycle only is safe if you use very specific atomic access functions).