04-02-2013 10:22 AM
Hi,
I am trying to understand the error handling code in the ANSI C examples for NIDAQmx.
For example, in the sample "MultVoltUpdates-SWTimed.c" (an analog output example), there is a macro near the top of the code
#define DAQmxErrChk(...
that is "wrapped" around all calls to NIDAQmx functions to check their return.
My question is this: if no errors are generated (say each call to an NIDAQmx function returns 0 for success) - how is the 'clean up' code that stops stops and clears the task called? It looks to me like the code under the label "Error:" would only execute if the macro DAQmxErrChk() generates a jump to the error label. But if every function successfully returns, "who" is responsible for calling the cleanup code that has to run even for successful execution, e.g., the stop and clear functions?
It may be part of the problem I'm having is understanding the block under the "Error:" label. I haven't been able to find a helpful (to me) discussion of using goto statements in C (since gotos so heavily frowned upon - though in this case, using a goto is the cleanest solution).
Also, in this particular example, the infinite loop is interrupted with "CTRL+C" key combo. How is the cleanup code called in this case - I suspect that a 'signal' is sent to the process to stop it when "CTRL+C" is pressed - how does the code 'capture' this and cleanup?
I'm trying to understand these so that I can build on this code.
Thanks for any help.
Jason
04-03-2013 05:43 PM - edited 04-03-2013 05:50 PM
Hi echemist,
Would you mind telling me what kind of hardware specific questions you have, like how to acquire data from a DAQ device in CVI?
I would recommend posting in the CVI forum for CVI specific questions (like syntax and error handling).
Best Regards,
04-07-2013 07:28 PM
Hi Bobby,
Thanks for your response. It seems I have chosen the wrong forum, since these are software questions. So the LabWindows/CVI board is the correct place for NIDAQmx ANSI C questions?
Jason
04-08-2013 10:06 AM
If you're trying to use a specific piece of hardware using LabWindows/CVI you're in the right place. For general programming questions (error handling in this case), I would head over there.
Best Regards,