Datatype problem and pointers for a .DLL

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 件のコメント

Philip Borghesani
Philip Borghesani 2015 年 10 月 8 日
What is the datatype of handlesensor? what does libfunctions -full say about CreateSenorInstance and SetParameterString? what is the c header line for these two functions? It is possible that the header is not being parsed correctly and a setdatatype on handlesensor or creating a prototype m file and fixing that may be the needed solution.
Torsten Fenn
Torsten Fenn 2015 年 10 月 9 日
If I write the code like this, handlesensor is of datatype double. I tried to convert it to ulong with a typecast, but it did not work for some reason.
CreateSensorInstance:
ulong CreateSensorInstance(ME_SENSOR)
SetParameterString:
[ERR_CODE, int8Ptr, int8Ptr] SetParameterString(ulong, int8Ptr, int8Ptr)
the c-header line is:
Private Declare Function SetParameterString Lib "MEDAQLib.dll" (ByVal instanceHandle As Long, ByVal paramName As String, ByVal paramValue As String)
Private Declare Function CreateSensorInstance Lib "MEDAQLib.dll" (ByVal sensor As Long)
I think the header is parsed correctly, since it's a corporate dll.
Lisa Petzold
Lisa Petzold 2019 年 8 月 2 日
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 2019 年 12 月 16 日
I do have the same issue. Did anyone find the solution, yet?

サインインしてコメントする。

回答 (2 件)

Subhamoy Saha
Subhamoy Saha 2020 年 1 月 20 日

1 投票

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 2019 年 10 月 30 日

0 投票

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')

カテゴリ

ヘルプ センター および File ExchangeC Shared Library Integration についてさらに検索

質問済み:

2015 年 10 月 8 日

回答済み:

2020 年 1 月 20 日

Community Treasure Hunt

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

Start Hunting!

Translated by