Link to home
Start Free TrialLog in
Avatar of opike
opike

asked on

Attempt to call dll function from matlab causing crash

I'm trying to use a third-party external DLL (from usbmicro) within matlab, but it keeps crashing matlab. This is from the documentation indicating the syntax of the function call from within a C program:

int USBm_About( char *about );

I tried this matlab script (yes it's very kludgy, I'm a matlab noob):
 
>> loadlibrary('USBm.dll','USBmAPI.h')
>> libfunctions('USBm')
>> s='sssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss';
>> st=strcat(s,s,s,s);
>> vp = libpointer('voidPtr',[int8(st) 0]);
>> result=calllib('USBm','USBm_About',vp)

Open in new window


and this matlab script:
 
>> loadlibrary('USBm.dll','USBmAPI.h')
>> libfunctions('USBm')
>> s='sssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss';
>> st=strcat(s,s,s,s);
>> vp=libpointer('cstring',st);
>> result=calllib('USBm','USBm_About',vp)

Open in new window


In both cases, the calllib() call causes matlab to crash with a segmentation fault.
SOLUTION
Avatar of graye
graye
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of opike
opike

ASKER

Went unresolved but awarding points in appreciation.