Calllib() call for a C character pointer, doesn't retrieve the whole string
Show older comments
I have the below function in my dll, which is loaded into MATLAB using loadlibrary() -
unsigned int DevId(unsigned int Chapterid,unsigned int SerialNum,CHAR* devid,unsigned int Len);
The corresponding function definition in MATLAB is -
[ulong, int8Ptr] DevId(long, ulong, int8Ptr, ulong)
I am trying to execute this function using calllib(), to retrive the "devid" , using the below matlab code
Cname=libpointer('int8Ptr',0);
CLen = 0;
calllib('<dll>','DevId',SID,CN,Cname,CLen);
When i try for 'Cname.Value', i get the output as "52" (which is the ASCII for 4,the first character of the string i should get) and CLen is still 0.
>> Cname.Value
ans =
int8
52
>> Clen
Clen =
0
Could you please let me know if i am doing something wrong.
String i am expecting as the output is 40-XXXA-XX2
Answers (1)
Alexander Jaiboy
on 14 Nov 2017
Categories
Find more on Scope Variables and Generate Names 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!