MATLAB troubles


#1

I can’t succesfully load the .h file in the API/MATLAB directory. However, I have no trouble working with the .h file in the API directory, but experience the documented memory leaks and eventually need to reboot the system.

I have matlab version 7.0.0.19920(R14)

This is the version of the .h file in the API/MATLAB directory:
Rev: 325 Date: 2006-08-07 23:21:07 -0700 (Mon, 07 Aug 2006)

Here is what matlab returns when I try to open the .h file that is in the API/MATLAB directory (I copied it into the API directory)

[CODE]path(path, ‘c:\program files\opal kelly\frontpanel\api’);
loadlibrary(‘okFrontPanel’, ‘okFrontPanelDLL.h’);
xid.ptr = calllib(‘okFrontPanel’, ‘okUsbXEM3001v2_Construct’);
[ret, x] = calllib(‘okFrontPanel’, ‘okUsbFrontPanel_Open’, xid.ptr, 0);
Warning: The function ‘okFrontPanelDLL_LoadLib’ was not found in the library

In loadlibrary at 218
Warning: The function ‘okFrontPanelDLL_FreeLib’ was not found in the library
In loadlibrary at 218
Warning: The function ‘okCPLL22393_GetReference’ was not found in the library
In loadlibrary at 218
Warning: The function ‘okUsbXEM3005_Construct’ was not found in the library
In loadlibrary at 218
Warning: The function ‘okUsbXEM3005_Destruct’ was not found in the library
In loadlibrary at 218
??? Error using ==> calllib
No method with matching signature.[/CODE]
When I proceed to make a call like

calllib(‘okFrontPanel’, ‘okUsbFrontPanel_UpdateWireOuts’, xid.ptr)
calllib(‘okFrontPanel’, ‘okUsbFrontPanel_GetWireOutValue’, xid.ptr, 32)

I don’t get an error, but the returned value is 512, which is not correct.

When I use the .h file provided in the API directory that causes memory leaks, everything works fine, until the system crashes due to the leaks.

Here’s an example of using the .h file that causes memory leaks.

[CODE]>> path(path, ‘c:\program files\opal kelly\frontpanel\api’);

loadlibrary(‘okFrontPanel’, ‘okFrontPanelDLL.h’);
xid.ptr = calllib(‘okFrontPanel’, ‘okUsbXEM3001v2_Construct’);
[ret, x] = calllib(‘okFrontPanel’, ‘okUsbFrontPanel_Open’, xid.ptr, 0);
Warning: The function ‘okFrontPanelDLL_LoadLib’ was not found in the library
In loadlibrary at 218
Warning: The function ‘okFrontPanelDLL_FreeLib’ was not found in the library
In loadlibrary at 218
Warning: The function ‘okCPLL22393_GetReference’ was not found in the library
In loadlibrary at 218
Warning: The function ‘okUsbXEM3005_Construct’ was not found in the library
In loadlibrary at 218
Warning: The function ‘okUsbXEM3005_Destruct’ was not found in the library
In loadlibrary at 218

calllib(‘okFrontPanel’, ‘okUsbFrontPanel_UpdateWireOuts’, xid.ptr)
calllib(‘okFrontPanel’, ‘okUsbFrontPanel_GetWireOutValue’, xid.ptr, 32)

ans =

   15474[/CODE]

15474 is the correct result.

Reid


#2

Reid-

Try copying the version from the API directory, but make the following change:

Where you see the typedefs for the _HANDLEs, change them to “unsigned long”. This is the stuff that Matlab has trouble with.

typedef void* okPLL22150_HANDLE;
typedef void* okPLL22393_HANDLE;
typedef void* okUSBFRONTPANEL_HANDLE;

#3

I actually already tried that, and got the same error. However, I have found the problem, and it is easily solved. The call

[ret, x] = calllib(‘okFrontPanel’, ‘okUsbFrontPanel_Open’, xid.ptr, 0);

gives an error because the return of the function okUsbFrontPanel_Open is not compatible with [ret, x] because of the handle changes in the updated .h file. I got the syntax

[ret, x] = calllib(‘okFrontPanel’, ‘okUsbFrontPanel_Open’, xid.ptr, 0);

from your users manual pdf file, page 57. The function returns 1, not a vector, which is what causes the error. You should probably update the users manual.

Thanks for the quick response. Your product is amazing! It has completely transformed my project from a serial interface to a MUCH faster, MUCH easier to use USB interface. I can’t emphasize enough how pleased I am with the final results!

Reid


#4

Reid-

Thanks for the feedback and kind comments. We apologize that the Matlab sample has not kept pace with the API. Without a seat for Matlab, we’re sort of in the dark for development.

But I’ll take a look and see if I can’t get things updated from your comments!