MATLAB Answers

Sarah
0

Arduino libraries stopped working in Simulink

Asked by Sarah
on 26 Jul 2017
Latest activity Answered by Saurabh Gupta on 27 Jul 2017
I have been using an S-function for an LCD in Simulink, which includes the Arduino source and header files LiquidCrystal.h and LiquidCrystal.cpp. This S-function has been working perfectly, but today I began encountering errors and the model will not build. It appears that Matlab no longer recognizes the syntax in the source and header files? Not sure why this is happening, but I was trying to create another S-function using the Wire and MAG3110 libraries and encountered the same issue. Below is the error for the LCD model.
In file included from C:/ProgramData/MATLAB/SupportPackages/R2017a/3P.instrset/arduinoide.instrset/idepkgs/packages/arduino/hardware/sam/1.6.7/cores/arduino/Print.h:27:0,
from C:/Users/slb0494/Desktop/LCD/LiquidCrystal.h:5,
from ../lcd_wrapper.c:19:
C:/ProgramData/MATLAB/SupportPackages/R2017a/3P.instrset/arduinoide.instrset/idepkgs/packages/arduino/hardware/sam/1.6.7/cores/arduino/Printable.h:25:1: error: unknown type name 'class'
class Print;
^
C:/ProgramData/MATLAB/SupportPackages/R2017a/3P.instrset/arduinoide.instrset/idepkgs/packages/arduino/hardware/sam/1.6.7/cores/arduino/Printable.h:33:1: error: unknown type name 'class'
class Printable
^
C:/ProgramData/MATLAB/SupportPackages/R2017a/3P.instrset/arduinoide.instrset/idepkgs/packages/arduino/hardware/sam/1.6.7/cores/arduino/Printable.h:34:1: error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token
{
^
In file included from C:/Users/slb0494/Desktop/LCD/LiquidCrystal.h:5:0,
from ../lcd_wrapper.c:19:
C:/ProgramData/MATLAB/SupportPackages/R2017a/3P.instrset/arduinoide.instrset/idepkgs/packages/arduino/hardware/sam/1.6.7/cores/arduino/Print.h:34:1: error: unknown type name 'class'
class Print
^
C:/ProgramData/MATLAB/SupportPackages/R2017a/3P.instrset/arduinoide.instrset/idepkgs/packages/arduino/hardware/sam/1.6.7/cores/arduino/Print.h:35:1: error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token
{
^
In file included from ../lcd_wrapper.c:19:0:
C:/Users/slb0494/Desktop/LCD/LiquidCrystal.h:45:1: error: unknown type name 'class'
class LiquidCrystal : public Print {
^
C:/Users/slb0494/Desktop/LCD/LiquidCrystal.h:45:21: error: expected '=', ',', ';', 'asm' or '__attribute__' before ':' token
class LiquidCrystal : public Print {
^
In file included from ../lcd_wrapper.c:20:0:
C:/Users/slb0494/Desktop/LCD/LiquidCrystal.cpp:27:14: error: expected '=', ',', ';', 'asm' or '__attribute__' before ':' token
LiquidCrystal::LiquidCrystal(uint8_t rs, uint8_t rw, uint8_t enable,
^
C:/Users/slb0494/Desktop/LCD/LiquidCrystal.cpp:34:14: error: expected '=', ',', ';', 'asm' or '__attribute__' before ':' token
LiquidCrystal::LiquidCrystal(uint8_t rs, uint8_t enable,
^
C:/Users/slb0494/Desktop/LCD/LiquidCrystal.cpp:41:14: error: expected '=', ',', ';', 'asm' or '__attribute__' before ':' token
LiquidCrystal::LiquidCrystal(uint8_t rs, uint8_t rw, uint8_t enable,
^
C:/Users/slb0494/Desktop/LCD/LiquidCrystal.cpp:47:14: error: expected '=', ',', ';', 'asm' or '__attribute__' before ':' token
LiquidCrystal::LiquidCrystal(uint8_t rs, uint8_t enable,
^
C:/Users/slb0494/Desktop/LCD/LiquidCrystal.cpp:53:19: error: expected '=', ',', ';', 'asm' or '__attribute__' before ':' token
void LiquidCrystal::init(uint8_t fourbitmode, uint8_t rs, uint8_t rw, uint8_t enable,
^
C:/Users/slb0494/Desktop/LCD/LiquidCrystal.cpp:78:19: error: expected '=', ',', ';', 'asm' or '__attribute__' before ':' token
void LiquidCrystal::begin(uint8_t cols, uint8_t lines, uint8_t dotsize) {
^
C:/Users/slb0494/Desktop/LCD/LiquidCrystal.cpp:167:19: error: expected '=', ',', ';', 'asm' or '__attribute__' before ':' token
void LiquidCrystal::setRowOffsets(int row0, int row1, int row2, int row3)
^
C:/Users/slb0494/Desktop/LCD/LiquidCrystal.cpp:176:19: error: expected '=', ',', ';', 'asm' or '__attribute__' before ':' token
void LiquidCrystal::clear()
^
C:/Users/slb0494/Desktop/LCD/LiquidCrystal.cpp:182:19: error: expected '=', ',', ';', 'asm' or '__attribute__' before ':' token
void LiquidCrystal::home()
^
C:/Users/slb0494/Desktop/LCD/LiquidCrystal.cpp:188:19: error: expected '=', ',', ';', 'asm' or '__attribute__' before ':' token
void LiquidCrystal::setCursor(uint8_t col, uint8_t row)
^
C:/Users/slb0494/Desktop/LCD/LiquidCrystal.cpp:202:19: error: expected '=', ',', ';', 'asm' or '__attribute__' before ':' token
void LiquidCrystal::noDisplay() {
^
C:/Users/slb0494/Desktop/LCD/LiquidCrystal.cpp:206:19: error: expected '=', ',', ';', 'asm' or '__attribute__' before ':' token
void LiquidCrystal::display() {
^
C:/Users/slb0494/Desktop/LCD/LiquidCrystal.cpp:212:19: error: expected '=', ',', ';', 'asm' or '__attribute__' before ':' token
void LiquidCrystal::noCursor() {
^
C:/Users/slb0494/Desktop/LCD/LiquidCrystal.cpp:216:19: error: expected '=', ',', ';', 'asm' or '__attribute__' before ':' token
void LiquidCrystal::cursor() {
^
C:/Users/slb0494/Desktop/LCD/LiquidCrystal.cpp:222:19: error: expected '=', ',', ';', 'asm' or '__attribute__' before ':' token
void LiquidCrystal::noBlink() {
^
C:/Users/slb0494/Desktop/LCD/LiquidCrystal.cpp:226:19: error: expected '=', ',', ';', 'asm' or '__attribute__' before ':' token
void LiquidCrystal::blink() {
^
C:/Users/slb0494/Desktop/LCD/LiquidCrystal.cpp:232:19: error: expected '=', ',', ';', 'asm' or '__attribute__' before ':' token
void LiquidCrystal::scrollDisplayLeft(void) {
^
C:/Users/slb0494/Desktop/LCD/LiquidCrystal.cpp:235:19: error: expected '=', ',', ';', 'asm' or '__attribute__' before ':' token
void LiquidCrystal::scrollDisplayRight(void) {
^
C:/Users/slb0494/Desktop/LCD/LiquidCrystal.cpp:240:19: error: expected '=', ',', ';', 'asm' or '__attribute__' before ':' token
void LiquidCrystal::leftToRight(void) {
^
C:/Users/slb0494/Desktop/LCD/LiquidCrystal.cpp:246:19: error: expected '=', ',', ';', 'asm' or '__attribute__' before ':' token
void LiquidCrystal::rightToLeft(void) {
^
C:/Users/slb0494/Desktop/LCD/LiquidCrystal.cpp:252:19: error: expected '=', ',', ';', 'asm' or '__attribute__' before ':' token
void LiquidCrystal::autoscroll(void) {
^
C:/Users/slb0494/Desktop/LCD/LiquidCrystal.cpp:258:19: error: expected '=', ',', ';', 'asm' or '__attribute__' before ':' token
void LiquidCrystal::noAutoscroll(void) {
^
C:/Users/slb0494/Desktop/LCD/LiquidCrystal.cpp:265:19: error: expected '=', ',', ';', 'asm' or '__attribute__' before ':' token
void LiquidCrystal::createChar(uint8_t location, uint8_t charmap[]) {
^
C:/Users/slb0494/Desktop/LCD/LiquidCrystal.cpp:275:26: error: expected '=', ',', ';', 'asm' or '__attribute__' before ':' token
inline void LiquidCrystal::command(uint8_t value) {
^
C:/Users/slb0494/Desktop/LCD/LiquidCrystal.cpp:279:28: error: expected '=', ',', ';', 'asm' or '__attribute__' before ':' token
inline size_t LiquidCrystal::write(uint8_t value) {
^
C:/Users/slb0494/Desktop/LCD/LiquidCrystal.cpp:287:19: error: expected '=', ',', ';', 'asm' or '__attribute__' before ':' token
void LiquidCrystal::send(uint8_t value, uint8_t mode) {
^
C:/Users/slb0494/Desktop/LCD/LiquidCrystal.cpp:303:19: error: expected '=', ',', ';', 'asm' or '__attribute__' before ':' token
void LiquidCrystal::pulseEnable(void) {
^
C:/Users/slb0494/Desktop/LCD/LiquidCrystal.cpp:312:19: error: expected '=', ',', ';', 'asm' or '__attribute__' before ':' token
void LiquidCrystal::write4bits(uint8_t value) {
^
C:/Users/slb0494/Desktop/LCD/LiquidCrystal.cpp:320:19: error: expected '=', ',', ';', 'asm' or '__attribute__' before ':' token
void LiquidCrystal::write8bits(uint8_t value) {
^
../lcd_wrapper.c:22:1: error: unknown type name 'LiquidCrystal'
LiquidCrystal lcd(12,11,5,4,3,2);
^
../lcd_wrapper.c:22:19: error: expected declaration specifiers or '...' before numeric constant
LiquidCrystal lcd(12,11,5,4,3,2);
^
../lcd_wrapper.c:22:22: error: expected declaration specifiers or '...' before numeric constant
LiquidCrystal lcd(12,11,5,4,3,2);
^
../lcd_wrapper.c:22:25: error: expected declaration specifiers or '...' before numeric constant
LiquidCrystal lcd(12,11,5,4,3,2);
^
../lcd_wrapper.c:22:27: error: expected declaration specifiers or '...' before numeric constant
LiquidCrystal lcd(12,11,5,4,3,2);
^
../lcd_wrapper.c:22:29: error: expected declaration specifiers or '...' before numeric constant
LiquidCrystal lcd(12,11,5,4,3,2);
^
../lcd_wrapper.c:22:31: error: expected declaration specifiers or '...' before numeric constant
LiquidCrystal lcd(12,11,5,4,3,2);
^
../lcd_wrapper.c: In function 'lcd_Outputs_wrapper':
../lcd_wrapper.c:53:5: error: 'lcd' undeclared (first use in this function)
lcd.setCursor(0,1);
^
../lcd_wrapper.c:53:5: note: each undeclared identifier is reported only once for each function it appears in
../lcd_wrapper.c: In function 'lcd_Update_wrapper':
../lcd_wrapper.c:74:5: error: 'lcd' undeclared (first use in this function)
lcd.begin(16,2);
^
gmake: *** [lcd_wrapper.o] Error 1
### Creating HTML report file Test_codegen_rpt.html

  0 Comments

Sign in to comment.

1 Answer

Answer by Saurabh Gupta on 27 Jul 2017

From the errors, it looks like you are calling C++ functions in lcd_wrapper.c, which is C source file. You may want to use extern "c" to inform the compiler/linker about it.

  0 Comments

Sign in to comment.