cstring datatypes in library function calls dll files
1 view (last 30 days)
Show older comments
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
0 Comments
Answers (1)
Philip Borghesani
on 2 Dec 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.
0 Comments
See Also
Categories
Find more on Call C from MATLAB 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!