Error using callib Method was not found
Show older comments
Hi,
I'm trying to call a function in my NIDAQ DLL, but it is not being recognized by matlab even though other functions are recognized. In general, to use calllib I understand that the syntax is: [x1,...,xN] = calllib(libname,funcname,arg1,...,argN)
What I have found is that when you purposefully remove arguments and outputs demanded by the function being called, matlab throws the error "No method with matching signature." when matlab recognizes the function in the header file. When matlab does not recognize the function in the header file, it instead returns "Method was not found"
The code I am using to test the dll is below. I have also attached a copy of the original header file saved as a text file.
Many Thanks! Thomas
%%Begin DAQ Test Code
if ~libisloaded('mynidaqmx')
disp('Matlab: Load nicaiu.dll')
warning('off','MATLAB:loadlibrary:TypeNotFound')
% This is to load ni library
loadlibrary('nicaiu.dll','nidaqmx.h','alias','mynidaqmx');
warning('on','MATLAB:loadlibrary:TypeNotFound')
%funclist = libfunctions('myni','-full')
%libfunctionsview('myni')
end
%Create task
%As defined in header file:
%int32 __CFUNC DAQmxCreateTask (const char taskName[], %TaskHandle %*taskHandle);
[status,taskname,taskhandle] = calllib('mynidaqmx','DAQmxCreateTask',[],uint32(1));
%Interpret error code
if status ~= 0
bufferSize = 500;
errorString = char(ones(1,bufferSize));
%As defined in header file:
%int32 __CFUNC DAQmxGetErrorString (int32 errorCode, char %errorString[], uInt32 bufferSize);
[status,errorString]=calllib('mynidaqmx','DAQmxGetErrorString', ...
status, errorString, bufferSize);
if ~isempty(errorString)
error(['Error ' num2str(errorCode) ': ' errorString]);
end
end
%Clear the task created above
%As defined in header file:
%int32 __CFUNC DAQmxStopTask (TaskHandle taskHandle);
[status]=calllib('mynidaqmx','DAQmxStopTask',taskhandle);
%As defined in header file:
%int32 __CFUNC DAQmxClearTask (TaskHandle taskHandle);
[status] = calllib('mynidaqmx','DAQmxClearTask',taskhandle);
%Matlab recognizes all functions up to this point. I can remove arugments
%and outputs from them and matlab will return the error "No method with
%matching signature."
%The function below is not recognized by matlab. I get the error "Method
%was not found." regardless of combinatorics of arguments and outputs
%As defined in header file:
%int32 __CFUNC_C DAQmxGetSystemInfoAttribute (int32 attribute, void *value, ...);
[ status, taskarray]= calllib('mynidaqmx','DAQmxGetSystemInfoAttribute', 'DAQmx_Sys_Tasks');
DAQmxErr(status);
Answers (0)
Categories
Find more on C Shared Library Integration in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!