Problems loading library mpusbapi.dll - unrecognised data types

조회 수: 5 (최근 30일)
Pawel Kekus
Pawel Kekus 2019년 8월 8일
답변: Kiran Felix Robert 2021년 6월 21일
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에서 Data Import and Analysis에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by