09-19-2018 12:21 PM
When I start an analog read task, set a breakpoint and wait for a while, the next read will throw due to the input buffer being full. I can increase the input buffer size to buy more time, but on resuming I will be acquiring the data that was put into the buffer. This essentially delays real time acquisition by however long I waited at the breakpoint.
How can I handle this? I don't care about the data the DAQ acquired while I waited at the breakpoint. There doesn't appear to be a way to clear the input buffer. I could have the software grab the data faster than the DAQ produces it to consume the buffer, but that introduces a dependency that should not be necessary. I tried setting SampleTimingType to OnDemand, but that slowed acquisition down to around 10Hz.
I'm using a cDAQ 9174 with a 9201 input module. Sampling at 1 kHz, setting the SampleClockRate to 1000 to achieve this.
09-20-2018 03:52 PM
Hi joeylaabs,
The issue here is that a breakpoint stops the code from executing on your PC, but the actual data acquisition is controlled by the DAQ device and doesn't depend on your code. Once your code tells it to start, it's just gonna keep going even if the code hangs up.
To get around this, you'll need to actually stop the DAQmx task before your breakpoint, then restart it after the breakpoint.
09-20-2018 04:00 PM
I understand that is the issue, thanks for writing it more clearly than I did.
Is there really no other way around this? It seems like a common enough use case that I hoped there would be a better solution.
09-21-2018 01:40 PM
Since the root cause is that the DAQ device is incapable of knowing that you've set a breakpoint in the PC code, there's not much else to be done.
I can tell you some options for clearing the buffer, but they also involve stopping the task:
Unreserving the device by using the Task.Control() method will clear out the buffer.
Changing the buffer size by using the InputBufferSize() property will clear out the buffer
For output tasks, changing the regeneration mode will clear the output buffer.
However, the first item will stop the task in order to perform the unreserve action, and the other 2 require the task to be inactive beforehand.