Okay, so I've contacted tech support about this, and what ended up solving it for me was changing the folder stucture, so that the src folder is now a subfolder of the +arduinoioaddons folder, and not the +ExampleAddon folder anymore. No idea why, but I can register my library now :)
Cannot register Custom Add-on Library
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Jana
le 3 Juil 2024
Réponse apportée : Eric Prandovsky
le 19 Sep 2024
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?
Réponse acceptée
Eric Prandovsky
le 19 Sep 2024
MATLAB recognizes it's an arduino addon based on the folder structure. For example when you install the NeoPixel addon stored in:
\Toolboxes\NeoPixel Add-On Library for Arduino\+arduinoioaddons\+Adafruit\src
If you go to the Toolboxes folder and the addon is grayed out, right click on the NeoPixel Add-On folder and select "Add to Path --> Selected folders" MATLAB automatically discovers that there is an Arduino Add-on in that folder based on the folder name +arduinoioaddons
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Lighting, Transparency, and Shading dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!