I have a C++ module whose purpose is to probe a user's system for available NI-DAQmx devices and their channels and ports. It used to work with the 7.1 driver set but now, with 7.4, it doesn't. Instead, when the channel name "/ai16" is passed to the DAQmxCreateAIVoltageChan function, it coughs up the following exception.
First-chance exception in [The process using my DLL.] (NIESXU.DLL): 0xC0000005: Access Violation.
This only occurs with strings on the type "/aiX" where X is any number outside the range of channels present. Complete nonsense names don't bother it, it just fails like you'd expect. I'm testing with a PCI-6014 at the moment that has only 15 AI channels so this used to just return the DAQmxErrorPhysicalChanDoesNotExist error that I trap to know when to stop counting. I catch the exception, of course, but I'd like it to not get thrown in the first place. What's happening with this now and can it be solved?
The relevant code section follows:
DAQmxCreateTask("Analog Input Counting", &taskHandle);
while(1)
{
str.Format("%s/ai%d", devices[i].name, devices[i].ai++);
status = DAQmxCreateAIVoltageChan(taskHandle, str, "", DAQmx_Val_Diff,
-10.0, 10.0, DAQmx_Val_Volts, NULL);
if(status != DAQmxErrorPhysicalChanDoesNotExist)
{
// Snipped for space. Fills out a large structure and updates a list.
}
else break;
}
devices[i].ai--;
DAQmxClearTask(taskHandle);