Problems loading library mpusbapi.dll - unrecognised data types

3 次查看(过去 30 天)
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.

回答(2 个)

Lorein Watson
Lorein Watson 2019-8-13
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.
  1 个评论
Pawel Kekus
Pawel Kekus 2019-8-13
Apologies if I didn't make it clear enough, but the mpusbapi.dll file was available on Matlab's path. I used it with LabVIEW on the same PC with no need to have it in the system folder. I still tried - placed it in System32 and tried running regsvr32, but just got a windows version compatibility error.
Reimage Repair does not seem like a trustworthy tool.

请先登录,再进行评论。


Kiran Felix Robert
Kiran Felix Robert 2021-6-21
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

类别

Help CenterFile Exchange 中查找有关 Startup and Shutdown 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by