Hello all,
I'm tring to do fairly simple things with NIDAQmx, but that thing's a beast and not all the functions are in the FP.
I managed to do a non-blocking signal generation like this, where a callback is called when the generation is finished:
DAQmxCreateTask("AnalogTask", &Task);
DAQmxCreateAOVoltageChan(Task, PhyChan, ChanName, -10, 10, DAQmx_Val_Volts, "");
DAQmxSetChanAttribute(Task, ChanName, DAQmx_AO_TermCfg, DAQmx_Val_RSE);
DAQmxCfgSampClkTiming(Task, "OnboardClock", Rate, DAQmx_Val_Rising, DAQmx_Val_FiniteSamps, NbSamplesPerChan);
DAQmxSetWriteAttribute(Task, DAQmx_Write_RegenMode, DAQmx_Val_AllowRegen);
DAQmxRegisterDoneEvent (Task, 0, CBD_AnalogEnd, NULL);
DAQmxWriteAnalogF64 (Task, AOSamples, 0, 0, DAQmx_Val_GroupByChannel, WriteArray, &SamplesWritten, 0);
// this returns immediately
DAQmxTaskControl (Task, DAQmx_Val_Task_Commit); // Necessary ?
DAQmxStartTask(Task); // this returns immediately
// Do something else - CBD_AnalogEnd will be called
But I can't do the same with analog input:
DAQmxCreateTask("AnalogTask", &Task);
DAQmxCreateAIVoltageChan(*Task, PhyChan, ChanName, DAQmx_Val_Cfg_Default, -10, 10, DAQmx_Val_Volts, NULL);
DAQmxCfgSampClkTiming (*Task, "OnboardClock", Rate, DAQmx_Val_Rising, DAQmx_Val_FiniteSamps, NbSamplesPerChan);
DAQmxSetReadAutoStart(Task, FALSE); // Undocumented function
DAQmxReadBinaryI16 (Task, AISamples, -1, DAQmx_Val_GroupByChannel, ReadArray, AISamples*4, &SamplesRead, 0);
DAQmxTaskControl (Task, DAQmx_Val_Task_Commit);
DAQmxStartTask(Task);
I get the following error message when calling ReadBinaryI16:
Read cannot be performed when the Auto Start property is false and the task is not running or committed.
Start the task before reading, or set Auto Start to true.
Property: DAQmx_Read_AutoStart
Corresponding Value: 0
Task Name: AnalogInTask
Status Code: -200473
If I place StartTask/TaskCommit before the ReadBinary call, I don't get any error but the read still takes the entire time before it returns. How does a non-bloacking read work ?
Thanks