MATLAB API Opening multiple devices

The two threads on the forum I have found that relate to this are from 2011:

I’m trying to use the commands from these threads so that I can eventually open up two FPGAs in MATLAB using their serial numbers. (I’d like to check that there are 2 FPGAs, Open 2 FPGAs, and then check their serial numbers to verify that the devices are correct).

Some code, such as that shown just below, outputs the expected result. (Checks that there are two FPGAs connected and returns the number of connected devices).


% Unload existent okFrontPanel library
if libisloaded(‘okFrontPanel’)
unloadlibrary(‘okFrontPanel’);
end

% Load okFrontPanel library
if ~libisloaded(‘okFrontPanel’)
loadlibrary(‘okFrontPanel’, ‘okFrontPanelDLL.h’);
end

%%% Check if 2 devices are connected %%%

xPointer = calllib(‘okFrontPanel’, ‘okFrontPanel_Construct’);
numDevices = calllib(‘okFrontPanel’, ‘okFrontPanel_GetDeviceCount’, xPointer);
if numDevices == 0
error(‘error: there are no devices connected’)
elseif numDevices == 1
error(‘error: there is only one device connected’)
elseif numDevices > 2
error(‘error: there are more than two devices connected’)
else
disp(‘There are two devices connected’)
end

Output:

There are two devices connected

numDevices =
2


There are other pieces of code where there seems to have been a change in the DLL such that the format of the input arguments for the functions has changed, see below.


Input:

% Unload existent okFrontPanel library
if libisloaded(‘okFrontPanel’)
unloadlibrary(‘okFrontPanel’);
end

% Load okFrontPanel library
if ~libisloaded(‘okFrontPanel’)
loadlibrary(‘okFrontPanel’, ‘okFrontPanelDLL.h’);
end

obj1 = calllib(‘okFrontPanel’, ‘okFrontPanel_Construct’);
[status, obj1x] = calllib(‘okFrontPanel’, ‘okFrontPanel_OpenBySerial’, obj1, ‘’);
serialNumber = calllib(‘okFrontPanel’, ‘okFrontPanel_GetDeviceListSerial’, obj1x, 0, ’ ', 10);

Output:

status =
‘ok_NoError’

Error using calllib
No method with matching signature.

Input:

serialNumber = calllib(‘okFrontPanel’, ‘okFrontPanel_GetDeviceListSerial’, obj1x, 0, ’ ');

Output:

serialNumber
serialNumber =
libpointer
serialNumber.Value
The datatype and size of the value must be defined before the value can be retrieved.
serialNumber.Datatype
ans =
‘voidPtr’


I get the error, “No method with matching signature.”. I have tried to change the arguments I give to the function to match those in okFrontPanelDLL.h. For example for GetDeviceListSerial:

okFrontPanel_GetDeviceListSerial(h, num, str);

When I do this, the function executes okay, but it returns a libpointer that I am unable to read.

Does anyone have experience with the MATLAB API and know where I’m going wrong? Is there somewhere I can look to see how I should be passing arguments to these functions? Or am I just reading the libpointer wrong?

Use

okFrontPanel_GetDeviceListSerial(h, num, blanks(30));