Cannot register Custom Add-on Library
I’ve written a custom add-on library to controll a stepper motor, however I’m having trouble registering it. I’ve both added the path via Set Path and tried running >>addpath(‘C:Users…’), but when I type in >>listArduinoLibraries, the add-on doesn’t show up.
The Current Folder browser looks excactly as shown here (https://de.mathworks.com/help/matlab/supportpkg/register-add-on-library.html), with only the src folder and its content appearing faded.
This is my C++ Header File:
# include "LibraryBase.h"
# include "Stepper.h"
// Command IDs
# define ROTATE_STEPPER 0x01
# define STEPPER_SPEED 0x02
class Stepper_L298N : public LibraryBase
{
private:
Stepper stepper;
public:
Stepper_L298N(MWArduinoClass& a, int stepsPerRevolution, int pin1, int pin2, int pin3, int pin4)
: stepper (stepsPerRevolution, pin1, pin2, pin3, pin4)
{
libName = "Stepper_L298N";
a.registerLibrary(this);
}
public:
void commandHandler(byte cmdID, byte* dataIn, unsigned int payloadSize)
{
switch (cmdID){
case ROTATE_STEPPER:{
int steps;
memcpy(&steps, dataIn, sizeof(int));
stepper.step(steps);
sendResponseMsg(cmdID, 0, 0);
break;
}
case STEPPER_SPEED:{
int speed;
memcpy(&speed, dataIn, sizeof(int));
stepper.setSpeed(speed);
sendResponseMsg(cmdID, 0, 0);
break;
}
default:{
}
}
}
};
The first part of my Add-On Class looks like this:
classdef Stepper_L298N < matlabshared.addon.LibraryBase
properties (Access = protected)
Pins
end
properties (Access = private, Constant = true)
ROTATE_STEPPER = hex2dec(’01’)
STEPPER_SPEED = hex2dec(’02’)
end
properties (Access = protected, Constant = true)
LibraryName = ‘Stepper_L298N’
DependentLibraries = {}
LibraryHeaderFiles = ‘Stepper.h’
CppHeaderFile = fullfile(arduinoio.FilePath(mfilename(‘fullpath’)), ‘src’, ‘Stepper_L298N.h’)
CppClassName = ‘Stepper_L298N’
end
I’ve checked for typos in the file names, but I can’t find any. Any advice what else could be wrong?I’ve written a custom add-on library to controll a stepper motor, however I’m having trouble registering it. I’ve both added the path via Set Path and tried running >>addpath(‘C:Users…’), but when I type in >>listArduinoLibraries, the add-on doesn’t show up.
The Current Folder browser looks excactly as shown here (https://de.mathworks.com/help/matlab/supportpkg/register-add-on-library.html), with only the src folder and its content appearing faded.
This is my C++ Header File:
# include "LibraryBase.h"
# include "Stepper.h"
// Command IDs
# define ROTATE_STEPPER 0x01
# define STEPPER_SPEED 0x02
class Stepper_L298N : public LibraryBase
{
private:
Stepper stepper;
public:
Stepper_L298N(MWArduinoClass& a, int stepsPerRevolution, int pin1, int pin2, int pin3, int pin4)
: stepper (stepsPerRevolution, pin1, pin2, pin3, pin4)
{
libName = "Stepper_L298N";
a.registerLibrary(this);
}
public:
void commandHandler(byte cmdID, byte* dataIn, unsigned int payloadSize)
{
switch (cmdID){
case ROTATE_STEPPER:{
int steps;
memcpy(&steps, dataIn, sizeof(int));
stepper.step(steps);
sendResponseMsg(cmdID, 0, 0);
break;
}
case STEPPER_SPEED:{
int speed;
memcpy(&speed, dataIn, sizeof(int));
stepper.setSpeed(speed);
sendResponseMsg(cmdID, 0, 0);
break;
}
default:{
}
}
}
};
The first part of my Add-On Class looks like this:
classdef Stepper_L298N < matlabshared.addon.LibraryBase
properties (Access = protected)
Pins
end
properties (Access = private, Constant = true)
ROTATE_STEPPER = hex2dec(’01’)
STEPPER_SPEED = hex2dec(’02’)
end
properties (Access = protected, Constant = true)
LibraryName = ‘Stepper_L298N’
DependentLibraries = {}
LibraryHeaderFiles = ‘Stepper.h’
CppHeaderFile = fullfile(arduinoio.FilePath(mfilename(‘fullpath’)), ‘src’, ‘Stepper_L298N.h’)
CppClassName = ‘Stepper_L298N’
end
I’ve checked for typos in the file names, but I can’t find any. Any advice what else could be wrong? I’ve written a custom add-on library to controll a stepper motor, however I’m having trouble registering it. I’ve both added the path via Set Path and tried running >>addpath(‘C:Users…’), but when I type in >>listArduinoLibraries, the add-on doesn’t show up.
The Current Folder browser looks excactly as shown here (https://de.mathworks.com/help/matlab/supportpkg/register-add-on-library.html), with only the src folder and its content appearing faded.
This is my C++ Header File:
# include "LibraryBase.h"
# include "Stepper.h"
// Command IDs
# define ROTATE_STEPPER 0x01
# define STEPPER_SPEED 0x02
class Stepper_L298N : public LibraryBase
{
private:
Stepper stepper;
public:
Stepper_L298N(MWArduinoClass& a, int stepsPerRevolution, int pin1, int pin2, int pin3, int pin4)
: stepper (stepsPerRevolution, pin1, pin2, pin3, pin4)
{
libName = "Stepper_L298N";
a.registerLibrary(this);
}
public:
void commandHandler(byte cmdID, byte* dataIn, unsigned int payloadSize)
{
switch (cmdID){
case ROTATE_STEPPER:{
int steps;
memcpy(&steps, dataIn, sizeof(int));
stepper.step(steps);
sendResponseMsg(cmdID, 0, 0);
break;
}
case STEPPER_SPEED:{
int speed;
memcpy(&speed, dataIn, sizeof(int));
stepper.setSpeed(speed);
sendResponseMsg(cmdID, 0, 0);
break;
}
default:{
}
}
}
};
The first part of my Add-On Class looks like this:
classdef Stepper_L298N < matlabshared.addon.LibraryBase
properties (Access = protected)
Pins
end
properties (Access = private, Constant = true)
ROTATE_STEPPER = hex2dec(’01’)
STEPPER_SPEED = hex2dec(’02’)
end
properties (Access = protected, Constant = true)
LibraryName = ‘Stepper_L298N’
DependentLibraries = {}
LibraryHeaderFiles = ‘Stepper.h’
CppHeaderFile = fullfile(arduinoio.FilePath(mfilename(‘fullpath’)), ‘src’, ‘Stepper_L298N.h’)
CppClassName = ‘Stepper_L298N’
end
I’ve checked for typos in the file names, but I can’t find any. Any advice what else could be wrong? arduino, add-on MATLAB Answers — New Questions