cstring datatypes in library function calls dll files

조회 수: 13 (최근 30일)
Katarzyna
Katarzyna 2014년 12월 2일
답변: Philip Borghesani 2014년 12월 2일
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

답변 (1개)

Philip Borghesani
Philip Borghesani 2014년 12월 2일
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.

카테고리

Help CenterFile Exchange에서 Call C from MATLAB에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by