Custom Arduino Library won't register.

조회 수: 10 (최근 30일)
Kevin Gilliam
Kevin Gilliam 2018년 2월 5일
댓글: Nicolas Petit 2021년 11월 17일
As the title suggests, I am trying to implement custom libraries with the Arduino support package, but I can't get them to register. I'm using 2017b on Windows 10. Support package is version 17.2.0.
I've tried with the three example tutorials (LCD, Ultrasonic, and HelloWorld), and no luck getting them to register.
I have definitely added my arduino libraries to the path, along with my working directory that has my package directories and .m files. I've un/re-installed the support packages (in admin mode and not) and no luck. I did the thing they suggest for troubleshooting here
Here is my HelloWorld.h file:
#include "LibraryBase.h"
class HelloWorld : public LibraryBase {
public:
HelloWorld(MWArduinoClass& a){
libName = "ExampleAddon/HelloWorld";
a.registerLibrary(this);
}
public:
void commandHandler(byte cmdID, byte* dataIn, unsigned int payloadSize){
switch (cmdID){
case 0x01:{
byte val [13] = "Hello World";
sendResponseMsg(cmdID, val, 13);
break;
}
default:{
// Do nothing
}
}
}
}
And here is my HelloWorld.m:
classdef HelloWorld < arduinoio.LibraryBase
properties(Access = private, Constant = true)
READ_COMMAND = hex2dec('01')
end
properties(Access = protected, Constant = true)
LibraryName = 'ExampleAddon/HelloWorld'
DependentLibraries = {}
ArduinoLibraryHeaderFiles = {}
CppHeaderFile = fullfile(arduinoio.FilePath(mfilename('fullpath')), 'src', 'HelloWorld.h')
CppClassName = 'HelloWorld'
end
methods
function obj = HelloWorld(parentObj)
obj.Parent = parentObj;
obj.Pins = [];
end
function out = read(obj)
cmdID = obj.READ_COMMAND;
inputs = [];
output = sendCommand(obj, obj.LibraryName, cmdID, inputs);
out = char(output);
end
end
end
No matter what I try, the end result is always the same:
6×1 cell array
{'Adafruit/MotorShieldV2'}
{'I2C' }
{'RotaryEncoder' }
{'SPI' }
{'Servo' }
{'ShiftRegister' }
Any thoughts? Thanks!
  댓글 수: 1
Madhu Govindarajan
Madhu Govindarajan 2018년 2월 5일
So when you say you tried the example tutorials LCD one - are you referring to this one here - https://www.mathworks.com/help/supportpkg/arduinoio/ug/add-lcd-library.html
If so, have you confirmed that when you are adding the files to the path that the subfolders are being included?
Are you getting any error messages/warning messages that are suppressed while you are following these tutorials?

댓글을 달려면 로그인하십시오.

채택된 답변

Menghan
Menghan 2018년 2월 5일
Hi Kevin,
I know you have tried with the example add-on, but just to confirm it again, can you run the following code in MATLAB where you have the support package installed?
>>addpath(fullfile(arduinoio.SPPKGRoot,'arduinoioexamples','SDKExampleHelloWorld'))
>>listArduinoLibraries
See if you get the HelloWorld addon registered. If not, please contact our Technical Support to get further help.
On a side note, you are missing a semicolon at the end of your class definition in the HelloWorld.h file. Each C++ class ends with it. It will cause arduino programming to fail, after the library register issue is solved.
Thanks,
Menghan
MATLAB Hardware Team
  댓글 수: 3
Charity Reed
Charity Reed 2020년 10월 9일
I'm having the same issue but all my directories are named correctly and I am still not able to get it to work. But when I tried Menghan's addpath line, that works but I still can't add my own libraries. Even my own helloworld
Nicolas Petit
Nicolas Petit 2021년 11월 17일
same thing. This does not work

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Custom Arduino Libraries에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by