Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

DAQmxStopTask hangs when no reference trigger seen

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

National Instruments - Tech Support
0 Kudos
Message 11 of 15
(993 Views)

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

 

0 Kudos
Message 12 of 15
(971 Views)

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

National Instruments - Tech Support
0 Kudos
Message 13 of 15
(967 Views)

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

0 Kudos
Message 14 of 15
(959 Views)

Hi Ian,

 

This sounds reasonable. Let me know how it goes!

 

Best Regards,

 

Chris

National Instruments - Tech Support
0 Kudos
Message 15 of 15
(957 Views)