cstring datatypes in library function calls dll files
10 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Réponses (1)
Philip Borghesani
le 2 Déc 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 commentaires
Voir également
Catégories
En savoir plus sur Call C from MATLAB dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!