Error Creating LCD Addon example

27 views (last 30 days)
Carlosgb86
Carlosgb86 on 14 Mar 2018
Answered: Deep ungefär 17 timmar ago
I want to create a custom arduino addon library for matlab and I tried to follow the example of the LCD Addon provided here. I am running matlab 2017b on windows 10. First of all, I found that following the exact steps provided in the example, the library could not be registered. After trying to instantiate it, I got the following error:
Abstract classes cannot be instantiated. Class 'arduinoioaddons.ExampleLCD.LCDAddon' inherits abstract methods or properties but does not implement them.
See the list of methods and properties that 'arduinoioaddons.ExampleLCD.LCDAddon' must implement if you do not intend the class to be abstract.
Abstract properties for class arduinoioaddons.ExampleLCD.LCDAddon:
ArduinoLibraryHeaderFiles % defined in arduinoio.LibraryBase
CppHeaderFile % defined in arduinoio.LibraryBase
Accordingly, I changed SourceHeaderFile for ArduinoLibraryHeaderFiles and CppClassHeaderFile for CppHeaderFile. After this change the library was succesfully registered but in trying to create an arduino object:
a = arduino('COM4','Uno','libraries','ExampleLCD/LCDAddon','Trace', true)
I got the following error message:
In file included from C:\ProgramData\MATLAB\SupportPackages\R2017b\3P.instrset\arduinoide.instrset\arduino-1.8.1\libraries\MWArduino\MWArduino.cpp:462:0:
C:\Users\berrocal\AppData\Local\Temp\ArduinoServer/LibraryRegistration.h:4:84: fatal error:
C:\Users\berrocal\Dropbox\Arduino\+arduinoioaddons\+ExampleLCD\src\LCD.h: No such file or directory
#include "C:\Users\berrocal\Dropbox\Arduino\+arduinoioaddons\+ExampleLCD\src\LCD.h"
^
compilation terminated.
I changed the name of the CppHeaderFile and CppClassName to match the header file name that I had created:
properties(Access = protected, Constant = true)
LibraryName = 'ExampleLCD/LCDAddon'
DependentLibraries = {}
ArduinoLibraryHeaderFiles = 'LiquidCrystal/LiquidCrystal.h'
CppHeaderFile= fullfile(arduinoio.FilePath(mfilename('fullpath')), 'src', 'LCDAddon.h')
CppClassName = 'LCDAddon'
end
Then I got a bunch of different errors, see the two first:
In file included from C:\ProgramData\MATLAB\SupportPackages\R2017b\3P.instrset\arduinoide.instrset\arduino-1.8.1\libraries\MWArduino\MWArduino.cpp:462:0:
LibraryRegistration.h:8: error: expected '}' at end of input
LCDAddon aLCDAddon(MWArduino); // ID = 0
^
In file included from C:\Users\berrocal\AppData\Local\Temp\ArduinoServer/LibraryRegistration.h:4:0,
from C:\ProgramData\MATLAB\SupportPackages\R2017b\3P.instrset\arduinoide.instrset\arduino-1.8.1\libraries\MWArduino\MWArduino.cpp:462:
C:\Users\berrocal\Dropbox\Arduino\+arduinoioaddons\+ExampleLCD\src\LCDAddon.h: In member function 'virtual void LCD::setup()':
C:\Users\berrocal\Dropbox\Arduino\+arduinoioaddons\+ExampleLCD\src\LCDAddon.h:31:9: error: 'cursorRow' was not declared in this scope
cursorRow = 0;
^
Since I am not used to OOP or C++, I am really clueless of what might be the problem. Anyone who can help me with this? See attached the C++ Header file (saved as .txt to be able to upload it) and the Matlab Addon wrapper.
  1 Comment
TAN NRM
TAN NRM on 8 Apr 2019
I have the same problem as you. Don't know if you can solve it yet?

Sign in to comment.

Answers (1)

Deep
Deep ungefär 17 timmar ago
The attached code files have some deviations from the documented tutorial, which include:
  • missing variable definitions
  • missing brackets
  • mismatching names for classes and methods.
I have attached the corrected files and included a screenshot of the code differences for your reference.
To avoid any manual copy-paste mistakes from the tutorial, MATLAB provides these examples within the support package installation folders. You can locate this folder for the Arduino support package by running the following command:
arduinoio.SPPKGRoot
You can read about this symbol using the inbuilt documentation command:
doc arduinoio.SPPKGRoot

Community Treasure Hunt

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

Start Hunting!