Error Creating LCD Addon example

36 ビュー (過去 30 日間)
Carlosgb86
Carlosgb86 2018 年 3 月 14 日
回答済み: Deep 2024 年 11 月 22 日 3:54
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 件のコメント
TAN NRM
TAN NRM 2019 年 4 月 8 日
I have the same problem as you. Don't know if you can solve it yet?

サインインしてコメントする。

回答 (1 件)

Deep
Deep 2024 年 11 月 22 日 3:54
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

カテゴリ

Help Center および File ExchangeCustom Arduino Libraries についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by