12-22-2010 09:46 AM
Hi IChodera,
I have been looking at you code and have noticed that you commented that you don't use the callback when you see the problem. Can you be absolutely certain of this? From the code you sent me it looks like it is called.
What happens if you run it without registering the callback at all?
Regards,
Chris
01-04-2011 05:24 AM
Hi Chris
Hope you had a good Christmas. Happy new year.
I have investigated, and yes the Every 'N' callback function does usually get called after the task is started. This in spite of the fact that I have disconnected the trigger signal!
Within the callback, the function DAQmxReadBinaryI16 either hangs or returns the error -88709
If I don't register the callback function the stop / clear task works as expected, without hanging.
So it looks like it is the spurious callback that is causing the problem. How can I work round this?
Regards
Ian
01-04-2011 07:24 AM
Hi Ian,
From a look at the callback, it would seem that the hang is caused because you have an infinite wait time for the trigger. If you replace this with a reasonable timeout then it won't hang for as long.
Other than not using the callback I can't think of how to get round it. How often does your code receive triggers normally? If you get triggers fairly regularly then a short timeout shouldn't be a problem. If your code does not receive them regularly then we may have to think of another solution.
Happy New Year!
Chris
01-04-2011 08:25 AM
Hi Chris
I think I see. I rather foolishly assumed that the "DAQmxRegisterEveryNSamplesEvent" registered a callback that was called every N samples acquired, hence I would see a full buffer every event. Presumably the callback occurs every N sample clocks irrespective of if the trigger has been seen or not?
So I just need to call the DAQmxReadBinaryI16 with a short (zero?) timeout and use the function "err" result and SamplesRead return value to determine when I have read all the results, following the trigger.
Thanks for your help
Ian
01-04-2011 08:28 AM
Hi Ian,
This sounds reasonable. Let me know how it goes!
Best Regards,
Chris