Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I pass a pointer to a TaskHandle in DAQmx?

I have a small problem
understanding how can I pass a pointer to a TaskHandle inside a class:

mycard.h
#include "NIDAQmx.h"

class mycard

{
public:
mycard();
~mycard();
uInt32 init();
uInt32 start(TaskHandle myHandle);
private:
TaskHandle mytaskHandle;
uInt32 status;
}

mycard.cpp
#include "NIDAQmx.h"
#include "mycard.h"

mycard::mycard()
{
mytaskHandle=0;
status=0;
}
mycard::~mycard()
{
}
uInt32 mycard::init()
{
status = DAQmxCreateTask("",mytaskHandle);
if(status!=0)
return status;
status =
DAQmxCreateAIVoltageChan(*mytaskHandle,"Dev1/ai0","",DAQmx_Val_NRSE,-10.0,10
.0,DAQmx_Val_Volts,NULL);
if(status!=0)
return status;
status = DAQmxCfgInputBuffer(*mytaskHandle,1000);
if(sta
tus!=0)
return status;
status =
DAQmxCfgSampClkTiming(*mytaskHandle,"",1000.0,DAQmx_Val_Rising,DAQmx_Val_Con
tSamps, 1000);
if(status!=0)
return status;
return status;
}
uInt32 mycard::start(TaskHandle myHandle)
{
status = DAQmxStartTask(myHandle);
return status;
}



When I call the start function, it reports error -200088, Task specified is
invalid or does not exist. If I call "DAQmxStartTask" in the Init function
it works well. My understanding is that I'm not passing the right pointer to
the task. How should a pointer to a TaskHandle be passed?
Laurentiu
0 Kudos
Message 1 of 2
(2,351 Views)
Hello laurentiu,

If I understood correctly what you are trying to do, you do not need a pointer to TaskHandle.

Just use your handle declaration: "TaskHandle mytaskHandle;"

Then pass the address for the handle in the DAQmxStartTask function: "status = DAQmxCreateTask("", &mytaskHandle);"

In the other functions from init just use the "mytaskHandle" value ex:"status = DAQmxCfgInputBuffer(mytaskHandle, 1000);"

The implementation of the start function is ok, and should remain unchanged.

Hope this helps,
krs
0 Kudos
Message 2 of 2
(2,351 Views)