Real-Time Measurement and Control

cancel
Showing results for 
Search instead for 
Did you mean: 

Latest NI-DAQmx 2025 Q2 Patch 1 cannot be used with C++ simulated device

With the latest NI-DAQmx I get a "DAQmx Error: Task specified is invalid or does not exist." when trying to start a simulated device using

DAQmxErrChk(Ni_CfgSampClkTiming(getHandle(), nullptr, sampleRate, DAQmx_Val_Rising, DAQmx_Val_ContSamps, getDeviceConfig()->getScanBlockSize()));

This works as expected in NI-DAQmx 2022 Q3. I simulate a NI USB-6210 and could not find any info that this device is not supported anymore.

What could be wrong and how can I fix it? Or if this cannot be fixed, what is the last version to support this device?

Thank you!

0 Kudos
Message 1 of 3
(211 Views)

Hi mael15,

 

Would it be possible to share the surrounding code? Especially the task creation. Since the issue might be related to code that is not shown in the screenshot.

 

What is the getHandle() function?

 

Best regards

Leonard

0 Kudos
Message 2 of 3
(96 Views)

this is the function starting the device:

DAQmxErrChk(Ni_CfgSampClkTiming(getHandle(), nullptr, sampleRate, DAQmx_Val_Rising, DAQmx_Val_ContSamps, getDeviceConfig()->getScanBlockSize()));
 
uInt32 val = 0;
DAQmxErrChk(Ni_GetBufInputBufSize(getHandle(), &val));

val = getDeviceConfig()->getScanBlockSize() * 125;
DAQmxErrChk(Ni_SetBufInputBufSize(getHandle(), val));
DAQmxErrChk(Ni_GetBufInputBufSize(getHandle(), &val));
 
DAQmxErrChk(NI_StartTask(getHandle()));
DAQmxErrChk(Ni_GetBufInputBufSize(getHandle(), &val));

getHandle() simple gets the TaskHandle that is created with the task:

const int numChn = ss->getIndexCursor()->getActiveChannelCount();
const wxString taskname = wxString::Format(wxT("%s-%iChannels"), getDeviceName(), numChn);
DAQmxErrChk(NI_CreateTask(taskname.mb_str(wxConvUTF8), &taskHandle));
DAQmxErrChk(NI_SetReadAttribute(getHandle(), DAQmx_Read_AutoStart, true));
 
// create channels
std::vector<wxString> physicalChn;
wxString phyChnStr = wxEmptyString;
for (int i = 0; i < getDeviceConfig()->getXYChannelCount() * 2; i++) {
	phyChnStr = getDeviceName() + wxT("/ai") + wxString::Format(wxT("%i"), i);
	physicalChn.push_back(phyChnStr);
}
 
const char* channelName[16] = { "1x", "1y", "2x", "2y", "3x", "3y", "4x", "4y", "5x", "5y", "6x", "6y", "7x", "7y", "8x", "8y" };
 
for (int k = 0; k < getDeviceConfig()->getXYChannelCount() * 2; k++) {
	char cstring[128] = "";
	strncpy(cstring, (const char*)physicalChn.at(k).mb_str(wxConvUTF8), 127);
	DAQmxErrChk(NI_CreateAIVoltageChannel(getHandle(), cstring, channelName[k], DAQmx_Val_RSE, -10, 10, DAQmx_Val_Volts, nullptr));
}
DAQmxErrChk(NI_RegisterEveryNSamplesEvent(getHandle(), DAQmx_Val_Acquired_Into_Buffer, getDeviceConfig()->getScanBlockSize(), 0, EveryNCallback, nullptr));
0 Kudos
Message 3 of 3
(14 Views)