Dear all, I am havind difficulties to call a function of a shared library. This function is defined in the C header like:
ssize_t myfun (const int id, void * buffer, size_t buffer_size_bytes, unsigned timeout)
First of all I am a bit confused because when I call "libfunctionsview" the argument "buffer_size_bytes" is listed as a voidPtr, but I was expecting an integer. However, I am unsure about the equivalence between size_t and Matlab types.
I have sample code in C:
unsigned long long buffer[1024]; ret = sc_tdc_pipe_read2(id, (void *)buffer, 1024*8, 50);
Whatever I am writing in Matlab, and honestly I started to write random code, is crashing Matlab.
I've tried:
[ret pp]= calllib('mylib','myfun',id,p,1024*8, 50)
or
[ret pp]= calllib('mylib','myfun',id,p,p2, 50)
with
pp = libpointer('voidPtr'); or
pp = libpointer('uint64Ptr'); or
pp = libpointer('voidPtr',uint64(zeros([1024 1]))); or
pp = libpointer('voidPtr',uint64(zeros([1 1024]))); or
pp = libpointer('voidPtr'); setdatatype(pp,'uint64',zeros([1024 1])); or
pp = libpointer('uint64Ptr');
and p2 = libpointer('voidPtr',1024*8);
Nothing worked. I am speaking with who wrote the DLL, but they are not experts in Matlab and I am no expert in C. Anyone that has experience with calllibe and somehow have any advice?
Kind regards,
Alessandro
Best Answer