Hello everyone,
I'm trying to use the DAQmx C library in Unity to receive signal from National Instruments hardware in Unity.
Because the C library is static and there is no .dll file, only .lib and header file, I created a wrapper dll that I chose which DAQmx method to integrate into Unity.
Currently I implemented the following methods:
DAQmxCreateTask(taskName, taskHandle);
DAQmxStopTask(taskHandle);
DAQmxStartTask(taskHandle);
DAQmxCreateAIVoltageChan(taskHandle, physicalChannel, nameToAssignToChannel, terminalConfig, minVal, maxVal, units, customScaleName);
DAQmxSetSampTimingType(taskHandle, data);
DAQmxReadAnalogF64(taskHandle, numSampsPerChan, timeout, fillMode, readArray, arraySizeInSamps, sampsPerChanRead, reserved);
DAQmxCfgSampClkTiming(taskHandle, source, rate, activeEdge, sampleMode, sampsPerChan);
DAQmxGetExtendedErrorInfo(errorString, bufferSize);
When I try to replicate this example "Acq-IntClk" in Unity, only my DAQmxCreateTask() call returned a 0, and when I call DAQmxCreateAIVoltageChan(); DAQmxCfgSampClkTiming(); DAQmxStartTask(); DAQmxReadAnalogF64(); they all returned error code -200088, which seemed to be this https://knowledge.ni.com/KnowledgeArticleDetails?id=kA00Z0000019QMjSAM&l=en-US , meaning "Task specified is invalid or does not exist."
Further more, when I try to use DAQmxGetExtendedErrorInfo() to get the error message, it doesn't seem to properly write value to the char[] I'm passing in. And it doesn't seem to work with string either. However when I try to pass an empty string (string errBuff = "";) with a char[] size of 2048, Unity will crash, which means that Unity is accessing the C library successfully? (DAQmxCreateTask() returns 0 should also prove this)
I'm a Unity developer, and I don't have any previous experience with DAQmx. I've successfully integrated and using other native library in Unity before, but I'm stuck on this one.