I am using Python inside of MATLAB to load a DLL so I can use its functionality. I have tried almost every combination of inputs to try and make this MATLAB-Python combo work, but I have been unsuccessful. I know my DLL is good because I have used it using solely python and I have also gotten it working in MATLAB using a different set of commands, but I really want to use the MATLAB/Python combo.
Below is what I am trying to do
ctypes = py.importlib.import_module('ctypes');
vnx = ctypes.cdll.LoadLibrary('file path where dll and header files are stored \vnx_fmsynth.dll');
vnx.fnLMS_GetNumDevices()
I can assure fnLMS_SetTestMode and fnLMS_GetNumDevices, are methods within the DLL but python-matlab does not want to recognize them. I have tried over 100 combinations of trying to get the DLL to function, but I simply cannot figure out the correct syntax. When I run essentially the same lines in python however, it does work, so I am obviously doing something wrong inside of matlab.
Let me show you what does work in MATLAB with out using python.. (this does require you have a C-code compiler installed on your PC).
cd('file path where dll and header files are stored')
loadlibrary([libName,'.dll'],'vnx_LMS_api.h')
libfunc= libfunctions('vnx_fmsynth')
libF.(libfunc{i})=libfunc{i};
calllib(libName, 'fnLMS_SetTestMode',0)
devNum=calllib(libName,libF.fnLMS_GetNumDevices)
I have included the files in .zip for you to try yourself.
the fnLMS_GetNumDevices function should response with '0'. the TestMode function doesn't respond with anything, but it does functionally work. I have been told and have watched videos that running python inside of MATLAB works the same, but I am starting to question my presumptions. :( Any and all help would be very much appreciated!!
I am using MATLAB 2022A