cstring datatypes in library function calls dll files

13 Ansichten (letzte 30 Tage)
Katarzyna
Katarzyna am 2 Dez. 2014
Hi! I'm trying to read data returned by my function: the mprototype is:
% extern " C " int getName( unsigned deviceIndex , char * nameBuffer , unsigned size );
fcns.name{fcnNum}='getName'; fcns.calltype{fcnNum}='cdecl'; fcns.LHS{fcnNum}='int32'; fcns.RHS{fcnNum}={'uint32', 'cstring', 'uint32'};fcnNum=fcnNum+1;
I run the function as:
buf = libpointer('cstring', blanks(200));
nam = calllib('pxc','pxcGetDeviceName',uint32(0),buf,uint32(200));
buf.Value
but all I get is blank string. So my question is: is the libpointer correct fot this usage of function? I'll be thanful for the help. KS

Antworten (1)

Philip Borghesani
Philip Borghesani am 2 Dez. 2014
Try :
[retval,name]=calllib('pxc','pxcGetDeviceName',0,blanks(200),200);
It is best to start by letting calllib do the data type conversion for you.

Kategorien

Mehr zu Call C from MATLAB finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by