NIDAQmx driver and example

John K.
Bacau,

Mar 11, 2011
55 Posts

0  |  0  

Re: NIDAQmx driver and example

Hi there! I have a big confusion here! I'm studying the NIDAQmx example program from the ATEasy install folder. In the example tests called "Analog In", "Analog Out" etc., at the end of the code, the statement "DAQ Task Clear()" appears, with no argument. If you will follow the steps where g_dwTaskHandle and g_DefaultTaskhandle appear, you will see that in the end, none of the code that pertains to ClearTask(dwTaskHandle) function will be run! Because "DAQ Task Clear()" with no argument means the value 0 is passed instead of "dwTaskHandle", and so neither one of the 3 "if" statements pertaining to the ClearTask(dwTaskhandle) function will be executed! So, this Clear() statement is not useful at all. If you take my oppionion, it should be done like this: "DAQ Task Clear(g_dwTaskHandle)". Anyone got my point? I hope to receive a reply from someone here....

Dale J.
La Verne, CA

Mar 16, 2011
22 Posts

0  |  0  

Re: NIDAQmx driver and example

Hi Alex,
The statement "DAQ Task Clear()" is an ATEasy Command that is linked to the procedure "ClearTask".  This procedure has the handle parameter included in it as an optional parameter.  The code for the ClearTask procedure shows that only the first IF statement is guaranteed to be skipped if the parameter is missing.  The other IF statements could execute if the g_dwTaskHandle or g_dwDefaultTaskHandle variables are equal to the default value for the optional parameter (0).  In this case, a new Task will be created.

However, I see your point.  If the g_dwTaskHandle or g_dwDefaultTaskHandle variables are not equal to the default value for the optional parameter, no code will execute and the task will not be cleared.  However, rather than reference the driver variable g_dwTaskHandle from the Program module, I would modify the driver and add an ELSE statement to the first IF statement:

! stop and close the handle
if dwTaskHandle
    CheckError(DAQmxClearTask(dwTaskHandle))
else
    CheckError(DAQmxClearTask(g_dwTaskHandle))
endif

Regards,
Dale

John K.
Bacau,

Mar 21, 2011
55 Posts

0  |  0  

Re: NIDAQmx driver and example

Thank you for your kind reply, Dale! I've passed this problem modifying the driver the way you pointed and, also, deleted the rest of the code which creates a new task. We have the DAQ Task Create() command for that, I don't see why to mix up. Anyway, thank you for your help! Keep in touch. Have a nice day!



Please Note
You need to have a M@GIC account to participate in the Forums.
Not yet registered on our website? Click here to register today!

All content, information and opinions presented on the Marvin Test Solutions User Forums are those of the authors of the posts and messages and not Marvin Test Solutions'. All attachments and files are downloaded at your own risk. [Read More]