Problems loading library mpusbapi.dll - unrecognised data types
4 views (last 30 days)
Show older comments
Hello,
I'm attempting to load the library mpusbapi.dll for control of hardware via USB ports. Only a 32-bit version of the library exists, so I'm loading it using the 32-bit version of Matlab 2015b (albeit on a 64-bit version of Windows 10).
Loading the library with the following:
[results,warnings] = loadlibrary('mpusbapi.dll','mpusbapi.h')
outputs the following warnings:
Warning: The data type 'error' used by function MPUSBGetDeviceCount does not exist.
> In loadlibrary
Warning: The data type 'error' used by function MPUSBOpen does not exist.
> In loadlibrary
%%%% etc...
and warnings contains the following:
Type 'HANDLE' was not found. Defaulting to type error.
Type 'PCHAR' was not found. Defaulting to type error.
Type 'PVOID' was not found. Defaulting to type error.
Type 'PDWORD' was not found. Defaulting to type error.
Type 'BOOL' was not found. Defaulting to type error.
%%%% repeated for every occurence
Moreover, loading the library using:
loadlibrary 'mpusbapi.dll' 'mpusbapi.h' mfilename prototype.m
the file prototype.m contains the following:
function [methodinfo,structs,enuminfo,ThunkLibName]=prototype
%PROTOTYPE Create structures to define interfaces found in 'mpusbapi'.
%This function was generated by loadlibrary.m parser version on Thu Aug 8 14:50:42 2019
%perl options:'mpusbapi.i -outfile=prototype.m'
ival={cell(1,0)}; % change 0 to the actual number of functions to preallocate the data.
structs=[];enuminfo=[];fcnNum=1;
fcns=struct('name',ival,'calltype',ival,'LHS',ival,'RHS',ival,'alias',ival);
ThunkLibName=[];
% DWORD MPUSBGetDLLVersion ( void );
fcns.name{fcnNum}='MPUSBGetDLLVersion'; fcns.calltype{fcnNum}='cdecl'; fcns.LHS{fcnNum}='uint32'; fcns.RHS{fcnNum}=[];fcnNum=fcnNum+1;
% DWORD MPUSBGetDeviceCount ( CHAR pVID_PID );
fcns.name{fcnNum}='MPUSBGetDeviceCount'; fcns.calltype{fcnNum}='cdecl'; fcns.LHS{fcnNum}='uint32'; fcns.RHS{fcnNum}={'error'};fcnNum=fcnNum+1;
% HANDLE MPUSBOpen ( DWORD instance , PCHAR pVID_PID , PCHAR pEP , DWORD dwDir , DWORD dwReserved );
fcns.name{fcnNum}='MPUSBOpen'; fcns.calltype{fcnNum}='cdecl'; fcns.LHS{fcnNum}='error'; fcns.RHS{fcnNum}={'uint32', 'error', 'error', 'uint32', 'uint32'};fcnNum=fcnNum+1;
% DWORD MPUSBRead ( HANDLE handle , PVOID pData , DWORD dwLen , PDWORD pLength , DWORD dwMilliseconds );
%%%% (and more of the same for the other functions...)
methodinfo=fcns;
I attempted manually editing PCHAR to CHAR, the latter obviously being a known datatype both in Windows and in Matlab, but it was still errored out. According to prototype.m, only integers (uint8, uint16, and uint32) were recognised.
I cannot figure out why the data types used in the .h file are not recognised, and I haven't been able to find anything useful online either. For reference, 32-bit LabVIEW 2018 has no problem loading and using the library on the same PC.
Any help or pointers would be greatly appreciated.
0 Comments
Answers (2)
Lorein Watson
on 13 Aug 2019
To fix the error you need download the mpusbapi.dll file and then reinstall it in the Windows system folder. So, else run the DLL Repair Tool, to fix the mpusbapi.dll corruption or errors.
Kiran Felix Robert
on 21 Jun 2021
Hi Pawel ,
Please refer the following answer thread for your problem.
You have replaced PCHAR with CHAR which is supported as a int8 or a int8ptr data type in MATLAB.
To have string data-type as input argument you can try using integer pointers.
Refer the following answer for details and a working example
0 Comments
See Also
Categories
Find more on Data Import and Analysis in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!