[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 904
  • Last Modified:

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.
0
opike
Asked:
opike
  • 2
2 Solutions
 
grayeCommented:
I presume you'd tried the simple approach first?

result=calllib('USBm','USBm_About',st)
0
 
opikeAuthor Commented:
We never figured this out but we moved on to something else.

Awarding the points in appreciation of the attempt.
0
 
opikeAuthor Commented:
Went unresolved but awarding points in appreciation.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now