Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/matlab/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在MATLAB中加载motorhawk动态链接库_Matlab_Dll_Loadlibrary - Fatal编程技术网

在MATLAB中加载motorhawk动态链接库

在MATLAB中加载motorhawk动态链接库,matlab,dll,loadlibrary,Matlab,Dll,Loadlibrary,我真的不是编程专家,所以我已经为我提出的愚蠢问题道歉了 我正试图以这种方式加载控制板的dll(来自pc control.co.uk的motorhawk) loadlibrary('hawk.dll', 'hawkdll.h', 'alias', 'hawk') 如果我检查库是否已加载 libisloaded('hawk') 我得到了积极的回应。但是,如果我要求使用刚刚加载的函数 libfunctions('hawk') 我没有得到任何函数,错误为lib.hawk method not fo

我真的不是编程专家,所以我已经为我提出的愚蠢问题道歉了

我正试图以这种方式加载控制板的dll(来自pc control.co.uk的motorhawk)

loadlibrary('hawk.dll', 'hawkdll.h', 'alias', 'hawk')
如果我检查库是否已加载

libisloaded('hawk')
我得到了积极的回应。但是,如果我要求使用刚刚加载的函数

libfunctions('hawk')
我没有得到任何函数,错误为lib.hawk method not found

我认为问题可能出在标题的书写方式上

///////////////////////////////////////////////
//          hawkdll.h
//        revision 1.3
//
//    All copyright PC Control Ltd. 2010
//      
///////////////////////////////////////////////
// DLL Function type definitions

// system defs
typedef int (*Type_Sys_Initialise)();               // find all devices connected and open USB paths to them
typedef int (*Type_Sys_GetMotorHawkCount)();        // find number of motor hawks connected
typedef int (*Type_Sys_GetSwitchingHawkCount)();    // find number of switching hawks connected
typedef int (*Type_Sys_GetServoHawkCount)();        // find number of servo hawks connected
typedef int (*Type_Sys_CloseAllDevices)();          // close all open paths to USB devices

// motor hawk defs
typedef int (*Type_Motor_SetType)(int devnum, int type);                // choose motor type (stepper or DC Motors)
typedef int (*Type_Motor_RunSteps)(int devnum, int steps);              // set the number of steps to execute
typedef int (*Type_Motor_SetDCMotors)(int devnum, int M1Speed, int M1Dir, int M2Speed, int M2Dir);      // set the speed and direction of both DC motors
typedef int (*Type_Motor_GetDCMotors)(int devnum, int *M1Speed, int *M1Dir, int *M2Speed, int *M2Dir);  // get the speed and direction of both DC motors from the specified board
typedef int (*Type_Motor_GetType)(int devnum, int *motor_type);                                         // get the type of motor currently configured for from the specified board
typedef int (*Type_Motor_GetStepper)(int devnum, int *direction, int *interval, int *step_mode, int *power, int *steps, int *run_mode, int *paused);            // get the current stepper motor settings from the specified board
typedef int (*Type_Motor_GetStepsRemaining)(int devnum, int *steps_remaining);          // get the current steps remaining from the specified board
typedef int (*Type_Motor_SetDigitalOutputs)(int devnum, int outputs);                   // set the digital outputs
typedef int (*Type_Motor_GetDigitalOutputs)(int devnum, int *outputs);                  // get the current settings of the digital outputs
typedef int (*Type_Motor_GetDigitalInputs)(int devnum, int *inputs);                    // get the current digital inputs
typedef int (*Type_Motor_SetLimitEnables)(int devnum, int m1_forward, int m1_reverse, int m2_forward, int m2_reverse);          // set the limit switch enables
typedef int (*Type_Motor_GetLimitEnables)(int devnum, int *m1_forward, int *m1_reverse, int *m2_forward, int *m2_reverse);      // get the current limit switch enable settings
typedef int (*Type_Motor_SetStepper)(int devnum, int direction, int interval, int step_mode, int power);                    // configure the stepper motor
typedef int (*Type_Motor_PauseStepper)(int devnum);                                     // temporarily pause the stepper motor
typedef int (*Type_Motor_ResumeStepper)(int devnum);                                    // resume running of the stepper motor
typedef int (*Type_Motor_StopStepper)(int devnum);                                      // stop the stepper motor and clear any remaining steps
typedef int (*Type_Motor_SetRunMode)(int devnum, int run_mode);                         // set the stepper running mode (once or continuous)
typedef int (*Type_Motor_ResetBoard)(int devnum);                                       // reset board

// switching hawk defs
typedef int (*Type_Switching_SetOutputs)(int devnum, int outputs);      // set the outputs
typedef int (*Type_Switching_GetOutputs)(int devnum, int *outputs);     // get the current outputs

// servo hawk defs
typedef int (*Type_Servo_SetServos)(int devnum, int Servo1, int Servo2, int Servo3, int Servo4, int Servo5, int Servo6, int Servo7, int Servo8);            // set the servos
typedef int (*Type_Servo_GetServos)(int devnum, int *Servo1, int *Servo2, int *Servo3, int *Servo4, int *Servo5, int *Servo6, int *Servo7, int *Servo8);    // get the current servo positions
typedef int (*Type_Servo_SetOutputs)(int devnum, int outputs);      // set the outputs
typedef int (*Type_Servo_GetOutputs)(int devnum, int *outputs);     // get the current outputs

///////////////////////////////////////////////
// other defs
#define STEP_MODE_FULL  1
#define STEP_MODE_HALF  2

#define POWER_ZERO          1
#define POWER_FRACTIONAL    2
#define POWER_MAX           3

#define MHK_STOPPED         0
#define MHK_FORWARD         1       // direction of DC motors
#define MHK_REVERSE         2

#define TYPE_STEPPER    0           // motor hawk is driving a stepper motor
#define TYPE_DCMOTORS   1           // motor hawk is driving two DC motors

#define STEPPER_RUN_ONCE        0   // run the specified steps once
#define STEPPER_RUN_CONTINUOUS  1   // run stepper continuously
有什么建议吗

谢谢你的帮助


戴维德首先,我建议您将负荷呼叫更改为

[notfound, warnings] = loadlibrary('hawk.dll', 'hawkdll.h', 'alias', 'hawk')
变量
notfound
将列出头文件中提到但在dll中找不到的任何函数<代码>警告也可以提供一些见解

一个可能的问题是如果HAK.DLL是C++库,Matlab只支持C风格的链接。如果是这样,你仍然可以在C++中编写DLL,但是你必须在每个函数定义和原型中添加<代码>外部> C >代码,并重新编译DLL。如果您没有访问源代码,您需要创建一个包装代码DLL,该代码带有代码>外部“C”< /代码>函数,然后调用C++函数。
<>你可以使用一个工具来确定Hok.dl的输出函数,如果是C或C++风格的链接。< /P>什么是错误,你在尝试什么?