This may well be my own ignorance, but in the exodriver, the methods directly returned values:
handle = calllib('liblabjackusb','LJUSB_OpenDevice',device,0,deviceID)
Making it easy to interface with MATLAB. But for LabJackM, only an error gets returned, and MATLAB doesn't modify the passed variables:
>> handle = int32(0);
>> error = calllib('libLabJackM','LJM_Open',int32(4),int32(1),'ANY',handle)
error = 0
handle = 0
>> calllib('libLabJackM','LJM_GetHandleInfo',handle,a,b,c,d,e,f)
ans =
1224
handle is not changed, although no error was found. Does anyone have an idea how to use the passed argument convention from MATLAB?
Hm, OK, answering my own question and hopefully at least helpful to some other
https://www.mathworks.com/help/releases/R2019b/matlab/matlab_external/pa...
>> nDevices = libpointer('int32Ptr',0); devType = libpointer('int32Ptr',0)
>> error = calllib('libLabJackM','LJM_ListAll',int32(0),int32(0),nDevices,devType,[],[],[])
error = 0
>> nDevices.Value
ans = int32 1
>> devType.Value
ans = int32 4
When a parameter is passed by reference, such as the handle in LJM_Open, in MATLAB the input is in the function parameter and the output (updated value) is in the function return. For example:
[error, handle] = calllib('libLabJackM', 'LJM_Open', int32(4), int32(1), 'ANY', handle)
After loading the library, you can view functions with libfunctionsview which displays the arguments and returns of functions.
Looks like you found an alternative solution with libpointer while I was typing my answer. Note with array parameters, their values get updated when passing the parameter, and not in the function return.
OK, thanks for your promp help, your support is excellent as always!