I am acquiring analogue data when a trigger event occurs. The event may take a while to happen, or the user may want to exit the program with no event having been received. This is a one shot event, and will be costly if it is missed. I would like to set the timeout on the data acquisition task to -1, i.e. wait indefinitely. But, if no event occurs and the user wants to exit, how to end the task which is waiting indefinitely for a trigger that is not going to come?
Solved! Go to Solution.
You could set a short timeout and put the DAQmx read in a loop. In the event the read times out, you can repeat the loop. If it doesn't timeout OR the user hits the stop button, then end the loop.
I considered this, but dont think it is suitable, because the event may be missed if the previous timeout happens just before the trigger event. Note I am interested in the data preceeding and after the event, hence the reference trigger and pre-samples. If insufficient presamples have been acquired the event will be ignored.
You'll have to try it to be sure, but I think it will work. Once you've executed the DAQmx Start Task which would be before the loop, the task should be armed and ready to go. The samples should be sitting in the buffer waiting for you to read them whenever the DAQmx Read gets around to reading them.
Yes, this does work. The presample data is not affected by looping the acquisition task.