Hi, I have a Matlab GUI accessing a USB device with its .dll The GUI accesses the USB data often i.e., it keeps calling the USB for data and plots it almost in real time. However, here is the problem. The first time GUI calls the USB and asks it to initialize and returns. Then after a while it asks the USB to start and send out data and this it does in a loop.
Now I tried to write a mex function for calling the USB and retrieving the data.
void init_USB_Mex(char *inputbf){USBINI Initialize;HINST hDLL;THis function loads the dll and initializes usinghDLL = LoadLibrary;andInitialize = (USBINI) GetProcAddress(hDLL, "_fname");andthenInitialize()}
It has a similar C++ routine for Start (Start_USB_Mex).
So my mex gateway routine keeps calling these functions using a check for input buf. If input buf says 'initialize' it runs the first C program and as the case maybe for subsequent calls.
However, for every call to Start, it has to go through the GetProcAddress followd by Start and then calling another Stop function to stop the USB. If I do not stop the USB and keep calling the Start function, I get segmentation error and Matlab hangs.
So how can I using mex keep calling Start-Stop without having to go through the GetProc… routine.
Is there a way I can define :static START start; in the mex function
I have up until now used the Matlab calllib functions. But now I want to move on to using C library GetProcAdd.
Structures in C do not have function members but C++ classes have those. And so if I have to pass member functions to mex is there a way? Hope I was clear in my problem statement. Thanks
Best Answer