I'm trying to run The IMU_Serial_EXemple of the APM2_Simulink_Blockset and i encountered some issues

1 view (last 30 days)
I followed the steps in the "How to report" (section 2 Setup)
the built failed when trying to dwnloading the code on the Ardunio Mega 2560 ( actually the hardware is the Ardupilot Mega 2.5).
Error
The call to realtime_make_rtw_hook, during the after_make hook generated the following error: The build failed with the following message: "C:/MATLAB/SupportPackages/R2013a/arduino-1.0/hardware/tools/avr/bin/avr-gcc" -I"C:/Users/JeanHermann/Desktop/pi3/Simulink_Ardupilot_Loridan_State2013 (1)/Matlab_Simulink/compare_dcm_rtt" -I"C:/Users/JeanHermann/Desktop/pi3/Simulink_Ardupilot_Loridan_State2013 (1)/Matlab_Simulink" -I"C:/Program Files/MATLAB/R2013a/extern/include" -I"C:/Program Files/MATLAB/R2013a/simulink/include" -I"C:/Program Files/MATLAB/R2013a/rtw/c/src" -I"C:/Program Files/MATLAB/R2013a/rtw/c/src/ext_mode/common" -I"C:/Program Files/MATLAB/R2013a/rtw/c/ert" -I"C:/MATLAB/SupportPackages/R2013a/arduino-1.0/hardware/arduino/cores/arduino" -I"C:/MATLAB/SupportPackages/R2013a/arduino-1.0/hardware/arduino/variants/mega" -I"C:/MATLAB/SupportPackages/R2013a/arduino/include" -I"C:/MATLAB/SupportPackages/R2013a/arduino-1.0/libraries/Servo" -mmcu=atmega2560 -std=gnu99 -Wall -Wstrict-prototypes -g -Os -D"MODEL=compare_dcm" -D"NUMST=1" -D"NCSTATES=0" -D"HAVESTDIO=" -D"ONESTEPFCN=0" -D"TERMFCN=1" -D"MAT_FILE=0" -D"MULTI_INSTANCE_CODE=0" -D"INTEGER_CODE=0" -D"MT=0" -D"CLASSIC_INTERFACE=0" -D"TID01EQ=0" -D"F_CPU=16000000" -D"_RUNONTARGETHARDWARE_BUILD_=" -D"_ROTH_MEGA2560_=" -D"_RTT_NUMSERVOS_=0" -c -x none ./HardwareSerial.cpp ./Print.cpp ./WInterrupts.c ./WMath.cpp ./WString.cpp ./new.cpp ./wiring.c ./wiring_analog.c ./wiring_digital.c ./io_wrappers.cpp ./compare_dcm.c ./compare_dcm_data.c ./ert_main.c ./rtGetInf.c ./rtGetNaN.c ./rt_nonfinite.c cc1plus.exe: warning: command line option "-Wstrict-prototypes" is valid for Ada/C/ObjC but not for C++ cc1plus.exe: warning: command line option "-std=gnu99" is valid for C/ObjC but not for C++ cc1plus.exe: warning: command line option "-Wstrict-prototypes" is valid for Ada/C/ObjC but not for C++ cc1plus.exe: warning: command line option "-std=gnu99" is valid for C/ObjC but not for C++ cc1plus.exe: warning: command line option "-Wstrict-prototypes" is valid for Ada/C/ObjC but not for C++ cc1plus.exe: warning: command line option "-std=gnu99" is valid for C/ObjC but not for C++ cc1plus.exe: warning: command line option "-Wstrict-prototypes" is valid for Ada/C/ObjC but not for C++ cc1plus.exe: warning: command line option "-std=gnu99" is valid for C/ObjC but not for C++ cc1plus.exe: warning: command line option "-Wstrict-prototypes" is valid for Ada/C/ObjC but not for C++ cc1plus.exe: warning: command line option "-std=gnu99" is valid for C/ObjC but not for C++ cc1plus.exe: warning: command line option "-Wstrict-prototypes" is valid for Ada/C/ObjC but not for C++ cc1plus.exe: warning: command line option "-std=gnu99" is valid for C/ObjC but not for C++ ./io_wrappers.cpp: In function 'void Serial_read(int, int, uint8_t*, int*)': ./io_wrappers.cpp:40: warning: 'libFcnOutput' may be used uninitialized in this function In file included from ./compare_dcm.c:17: ./compare_dcm.h:27:35: error: Simulink_APM2_Wrapper.h: No such file or directory ./compare_dcm.c: In function 'compare_dcm_output': ./compare_dcm.c:342: warning: implicit declaration of function 'pinMode' ./compare_dcm.c:342: error: 'OUTPUT' undeclared (first use in this function) ./compare_dcm.c:342: error: (Each undeclared identifier is reported only once ./compare_dcm.c:342: error: for each function it appears in.) ./compare_dcm.c:343: warning: implicit declaration of function 'digitalWrite' ./compare_dcm.c:343: error: 'HIGH' undeclared (first use in this function) ./compare_dcm.c:344: warning: implicit declaration of function 'imu_update' ./compare_dcm.c:345: warning: implicit declaration of function 'imu_get_gyros' ./compare_dcm.c:346: warning: implicit declaration of function 'imu_get_accels' ./compare_dcm.c:347: warning: implicit declaration of function 'imu_temperature' ./compare_dcm.c:620: warning: implicit declaration of function 'Serial_printfloats' ./compare_dcm.c: In function 'compare_dcm_initialize': ./compare_dcm.c:876: warning: implicit declaration of function 'Simulink_APM2_Startup' ./compare_dcm.c:881: warning: implicit declaration of function 'imu_init' ./compare_dcm.c:886: warning: implicit declaration of function 'Serial_begin' In file included from ./compare_dcm_data.c:17: ./compare_dcm.h:27:35: error: Simulink_APM2_Wrapper.h: No such file or directory In file included from ./ert_main.c:17: ./compare_dcm.h:27:35: error: Simulink_APM2_Wrapper.h: No such file or directory In file included from ./ert_main.c:18: C:/MATLAB/SupportPackages/R2013a/arduino-1.0/hardware/arduino/cores/arduino/Arduino.h:24:1: warning: "true" redefined In file included from ./compare_dcm.h:24, from ./ert_main.c:17: ./rtwtypes.h:158:1: warning: this is the location of the previous definition In file included from ./ert_main.c:18: C:/MATLAB/SupportPackages/R2013a/arduino-1.0/hardware/arduino/cores/arduino/Arduino.h:25:1: warning: "false" redefined In file included from ./compare_dcm.h:24, from ./ert_main.c:17: ./rtwtypes.h:154:1: warning: this is the location of the previous definition make: * [HardwareSerial.o] Error 1
The build process will terminate as a result.
Caused by: The build failed with the following message: "C:/MATLAB/SupportPackages/R2013a/arduino-1.0/hardware/tools/avr/bin/avr-gcc" -I"C:/Users/JeanHermann/Desktop/pi3/Simulink_Ardupilot_Loridan_State2013 (1)/Matlab_Simulink/compare_dcm_rtt" -I"C:/Users/JeanHermann/Desktop/pi3/Simulink_Ardupilot_Loridan_State2013 (1)/Matlab_Simulink" -I"C:/Program Files/MATLAB/R2013a/extern/include" -I"C:/Program Files/MATLAB/R2013a/simulink/include" -I"C:/Program Files/MATLAB/R2013a/rtw/c/src" -I"C:/Program Files/MATLAB/R2013a/rtw/c/src/ext_mode/common" -I"C:/Program Files/MATLAB/R2013a/rtw/c/ert" -I"C:/MATLAB/SupportPackages/R2013a/arduino-1.0/hardware/arduino/cores/arduino" -I"C:/MATLAB/SupportPackages/R2013a/arduino-1.0/hardware/arduino/variants/mega" -I"C:/MATLAB/SupportPackages/R2013a/arduino/include" -I"C:/MATLAB/SupportPackages/R2013a/arduino-1.0/libraries/Servo" -mmcu=atmega2560 -std=gnu99 -Wall -Wstrict-prototypes -g -Os -D"MODEL=compare_dcm" -D"NUMST=1" -D"NCSTATES=0" -D"HAVESTDIO=" -D"ONESTEPFCN=0" -D"TERMFCN=1" -D"MAT_FILE=0" -D"MULTI_INSTANCE_CODE=0" -D"INTEGER_CODE=0" -D"MT=0" -D"CLASSIC_INTERFACE=0" -D"TID01EQ=0" -D"F_CPU=16000000" -D"_RUNONTARGETHARDWARE_BUILD_=" -D"_ROTH_MEGA2560_=" -D"_RTT_NUMSERVOS_=0" -c -x none ./HardwareSerial.cpp ./Print.cpp ./WInterrupts.c ./WMath.cpp ./WString.cpp ./new.cpp ./wiring.c ./wiring_analog.c ./wiring_digital.c ./io_wrappers.cpp ./compare_dcm.c ./compare_dcm_data.c ./ert_main.c ./rtGetInf.c ./rtGetNaN.c ./rt_nonfinite.c cc1plus.exe: warning: command line option "-Wstrict-prototypes" is valid for Ada/C/ObjC but not for C++ cc1plus.exe: warning: command line option "-std=gnu99" is valid for C/ObjC but not for C++ cc1plus.exe: warning: command line option "-Wstrict-prototypes" is valid for Ada/C/ObjC but not for C++ cc1plus.exe: warning: command line option "-std=gnu99" is valid for C/ObjC but not for C++ cc1plus.exe: warning: command line option "-Wstrict-prototypes" is valid for Ada/C/ObjC but not for C++ cc1plus.exe: warning: command line option "-std=gnu99" is valid for C/ObjC but not for C++ cc1plus.exe: warning: command line option "-Wstrict-prototypes" is valid for Ada/C/ObjC but not for C++ cc1plus.exe: warning: command line option "-std=gnu99" is valid for C/ObjC but not for C++ cc1plus.exe: warning: command line option "-Wstrict-prototypes" is valid for Ada/C/ObjC but not for C++ cc1plus.exe: warning: command line option "-std=gnu99" is valid for C/ObjC but not for C++ cc1plus.exe: warning: command line option "-Wstrict-prototypes" is valid for Ada/C/ObjC but not for C++ cc1plus.exe: warning: command line option "-std=gnu99" is valid for C/ObjC but not for C++ ./io_wrappers.cpp: In function 'void Serial_read(int, int, uint8_t*, int*)': ./io_wrappers.cpp:40: warning: 'libFcnOutput' may be used uninitialized in this function In file included from ./compare_dcm.c:17: ./compare_dcm.h:27:35: error: Simulink_APM2_Wrapper.h: No such file or directory ./compare_dcm.c: In function 'compare_dcm_output': ./compare_dcm.c:342: warning: implicit declaration of function 'pinMode' ./compare_dcm.c:342: error: 'OUTPUT' undeclared (first use in this function) ./compare_dcm.c:342: error: (Each undeclared identifier is reported only once ./compare_dcm.c:342: error: for each function it appears in.) ./compare_dcm.c:343: warning: implicit declaration of function 'digitalWrite' ./compare_dcm.c:343: error: 'HIGH' undeclared (first use in this function) ./compare_dcm.c:344: warning: implicit declaration of function 'imu_update' ./compare_dcm.c:345: warning: implicit declaration of function 'imu_get_gyros' ./compare_dcm.c:346: warning: implicit declaration of function 'imu_get_accels' ./compare_dcm.c:347: warning: implicit declaration of function 'imu_temperature' ./compare_dcm.c:620: warning: implicit declaration of function 'Serial_printfloats' ./compare_dcm.c: In function 'compare_dcm_initialize': ./compare_dcm.c:876: warning: implicit declaration of function 'Simulink_APM2_Startup' ./compare_dcm.c:881: warning: implicit declaration of function 'imu_init' ./compare_dcm.c:886: warning: implicit declaration of function 'Serial_begin' In file included from ./compare_dcm_data.c:17: ./compare_dcm.h:27:35: error: Simulink_APM2_Wrapper.h: No such file or directory In file included from ./ert_main.c:17: ./compare_dcm.h:27:35: error: Simulink_APM2_Wrapper.h: No such file or directory In file included from ./ert_main.c:18: C:/MATLAB/SupportPackages/R2013a/arduino-1.0/hardware/arduino/cores/arduino/Arduino.h:24:1: warning: "true" redefined In file included from ./compare_dcm.h:24, from ./ert_main.c:17: ./rtwtypes.h:158:1: warning: this is the location of the previous definition In file included from ./ert_main.c:18: C:/MATLAB/SupportPackages/R2013a/arduino-1.0/hardware/arduino/cores/arduino/Arduino.h:25:1: warning: "false" redefined In file included from ./compare_dcm.h:24, from ./ert_main.c:17: ./rtwtypes.h:154:1: warning: this is the location of the previous definition make: * [HardwareSerial.o] Error 1
Maybe i did'nt modify well the src/io_wrappers.cpp and the include/io_wrappers.h
include/io_wrappers.h
/* * Wrappers to make I/O functions available with C linkage. This allows C++ * methods to be called from C code. * * Copyright 2011-2012 The MathWorks, Inc. */
#include inttypes.h #include stdio.h /* for size_t */
#if 0 void Serial_begin(int port, long r); void Serial_read(int port, int showOutStatus, uint8_t *outData, int *outStatus); void Serial_write(int port, uint8_t * c, size_t s);
#if RTT_NUMSERVOS != 0 void MW_servoAttach(uint8_t nServo, uint8_t pinNumber); void MW_servoWrite(uint8_t nServo, uint8_t inValue); int MW_servoRead(uint8_t nServo); #endif
#endif
src/io_wrappers.cpp
#if 0 /* * Wrappers to make I/O functions available with C linkage. This allows C++ * methods to be called from C code. * * Copyright 2012 The MathWorks, Inc. */
#include inttypes.h #include "Arduino.h" #include "Servo.h"
extern "C" { void __cxa_pure_virtual(void); }
extern "C" void Serial_begin(int port, long r) { #ifdef ROTH_MEGA2560 switch(port) { case 0: Serial.begin(r); break; case 1: Serial1.begin(r); break; case 2: Serial2.begin(r); break; case 3: Serial3.begin(r); break; } #else Serial.begin(r); #endif }
extern "C" void Serial_read(int port, int showOutStatus, uint8_t outData, int *outStatus) { int libFcnOutput; #ifdef ROTH_MEGA2560 / Could do without this conditional */ switch(port) { case 0: libFcnOutput = Serial.read(); break; case 1: libFcnOutput = Serial1.read(); break; case 2: libFcnOutput = Serial2.read(); break; case 3: libFcnOutput = Serial3.read(); break; } #else libFcnOutput = Serial.read(); #endif *outData = (uint8_t) libFcnOutput; *outStatus = (libFcnOutput != -1); }
extern "C" void Serial_write(int port, uint8_t * c, size_t s) { #ifdef ROTH_MEGA2560 switch(port) { case 0: Serial.write(c, s); break; case 1: Serial1.write(c, s); break; case 2: Serial2.write(c, s); break; case 3: Serial3.write(c, s); break; } #else Serial.write(c, s); #endif }
#if RTT_NUMSERVOS != 0 Servo myservos[_RTT_NUMSERVOS_];
extern "C" void MW_servoAttach(uint8_t nServo, uint8_t pinNumber) { myservos[nServo].attach(pinNumber); }
extern "C" void MW_servoWrite(uint8_t nServo, uint8_t inValue) { myservos[nServo].write(inValue); }
extern "C" int MW_servoRead(uint8_t nServo) { return myservos[nServo].read(); } #endif #endif
  4 Comments

Sign in to comment.

Answers (1)

ladi
ladi on 23 Nov 2013
Edited: ladi on 23 Nov 2013
You are using MATLAB 2013a. I have encountered with the same problem and using 2012b (version they created the block set) resolved the problem for me. Also dont forget to edit directory location in mex script.
  1 Comment
Fotis
Fotis on 9 Apr 2014
Hi ladi! I encountered the same issue in both 2012b and 2013a. Can you please outline the steps you followed to resolve this issue?
I'm using APM 2.6. I get an error "The call to realtime_make_rtw_hook, during the after_make hook generated the following error: The build failed with the following message: "C:/MATLAB/Targets/R2012b/arduino-1.0/hardware/tools/avr/bin/avr-gcc" -I"C:/Users/SACL_Network/Documents/MATLAB/ArduPilot/APM2/Magnetometer_test_v1_rtt"....." Also I get messages along the lines "cc1plus.exe: warning: command line option "-Wstrict-prototypes" is valid for Ada/C/ObjC but not for C++", so I assume it is related to the C codes run under C++.
Are you using the ArduPilot-Arduino-1.0.3-windows IDE?
Any feedback would be greatly appreciated as I have spent a week without any results...
Thanks!
Fotis

Sign in to comment.

Categories

Find more on Upgrading Hydraulic Models to Use Isothermal Liquid Blocks in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!