Datatype problem and pointers for a .DLL

9 views (last 30 days)
Torsten Fenn
Torsten Fenn on 8 Oct 2015
Answered: Subhamoy Saha on 20 Jan 2020
Hi I have a problem with the following code:
loadlibrary(fullpathToDll, fullpathToHeader)
handlesensor = calllib('MEDAQLib', 'CreateSensorInstance',2) % = SENSOR_ILD1700
calllib('MEDAQLib','SetParameterString',handlesensor,'IP_Interface', 'IF2004_USB');
MATLAB returns an error message in line 3 where I use calllib:
Error using calllib
Array must be numeric or logical or a pointer to one
The code works just fine in C when I use:
hSensor = CreateSenorInstance(2); // = SENSOR_ILD1700
SetParameterString(hSensor, "IP_Interface", "IF2004_USB");
I think the problem is the datatype, but everything I tried did not work. From the documentation I know that the parameters of the function SetParameterString are declared like this:
DWORD handlesensor, LPCSTR paramname, LPCSTR value
I hope you can help me with the information I provided. Thanks!
  4 Comments
Lisa Petzold
Lisa Petzold on 2 Aug 2019
Did anyone find a solution to Torstens Problem?
I am having the same Problem as I am tyring to use the MEDAQLib from Micro-Epsilon to read a sensor from the company.
Thanks a lot!
Petros Neoptolemou
Petros Neoptolemou on 16 Dec 2019
I do have the same issue. Did anyone find the solution, yet?

Sign in to comment.

Answers (2)

Subhamoy Saha
Subhamoy Saha on 20 Jan 2020
Yeah! I have returned with an answer this time. The error causes due to declration problem of this line
DWORD handlesensor, LPCSTR paramname, LPCSTR value
You need to follow this format
[ERR_CODE, int8Ptr, int8Ptr] SetParameterString (ulong, int8Ptr, int8Ptr)
Use the following code
loadlibrary(fullpathToDll, fullpathToHeader)
handlesensor = calllib('MEDAQLib', 'CreateSensorInstance',2) % = SENSOR_ILD1700
calllib('MEDAQLib','SetParameterString',handlesensor,int8('IP_Interface'), int8('IF2004_USB'));
Please let us know whether it worked or not.

Subhamoy Saha
Subhamoy Saha on 30 Oct 2019
I have IFD2421 sensor connected over TCP/IP and mine is working fine. You did the same thing and the error should not come. Sorry, I could not help you out but let you know soon if possible.
hSensor =calllib('MEDAQLib','CreateSensorInstance','SENSOR_IFD2421')
calllib('MEDAQLib','SetParameterString',hSensor,'IP_Interface','TCP/IP')

Categories

Find more on Data Import and Export in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!