error: cannot call member function 'float LPS::readP​ressureMil​libars()' without object float pressure = LPS::readP​ressureMil​libars();

1 次查看(过去 30 天)
Hello everyone;
I'm making a S-function block, with the code from Arduino.
I tested the code from Arduino and it works fine, but when I made the S-function builder I receive this error:
Ons/TOOLBO~1/EMBEDD~1/code/ENERGI~1/@SLCUS~1/../SCHEDU~1/include -IC:/Users/Alberto/DOCUME~1/MATLAB/Add-Ons/TOOLBO~1/EMBEDD~1/code/COMMON~1/include -o "Prueba_wrapper.o" "../Prueba_wrapper.cpp"
../Prueba_wrapper.cpp: In function 'void Prueba_Outputs_wrapper(real_T*, const real_T*)':
../Prueba_wrapper.cpp:42:47: error: cannot call member function 'float LPS::readPressureMillibars()' without object
float pressure = LPS::readPressureMillibars();
^
../Prueba_wrapper.cpp:44:45: error: cannot call member function 'float LPS::readTemperatureC()' without object
float temperature = LPS::readTemperatureC();
^
../Prueba_wrapper.cpp: In function 'void Prueba_Update_wrapper(real_T*, real_T*)':
../Prueba_wrapper.cpp:70:6: error: 'ps' was not declared in this scope
if (!ps.init())
^
../Prueba_wrapper.cpp:75:1: error: 'ps' was not declared in this scope
ps.enableDefault();
^
gmake: *** [Prueba_wrapper.o] Error 1
### Creating HTML report file untitled_codegen_rpt.html
### Build procedure for model: 'untitled' aborted due to an error.
This is the Prueba_wrapper.cpp file generated by the builder:
/*
* Include Files
*
*/
#if defined(MATLAB_MEX_FILE)
#include "tmwtypes.h"
#include "simstruc_types.h"
#else
#include "rtwtypes.h"
#endif
/* %%%-SFUNWIZ_wrapper_includes_Changes_BEGIN --- EDIT HERE TO _END */
# ifndef MATLAB_MEX_FILE
# include <Arduino.h>
# include <math.h>
# include <Wire.h>
# include <LPS.h>
# include <LPS.cpp>
# endif
/* %%%-SFUNWIZ_wrapper_includes_Changes_END --- EDIT HERE TO _BEGIN */
#define y_width 1
/*
* Create external references here.
*
*/
/* %%%-SFUNWIZ_wrapper_externs_Changes_BEGIN --- EDIT HERE TO _END */
/* extern double func(double a); */
/* %%%-SFUNWIZ_wrapper_externs_Changes_END --- EDIT HERE TO _BEGIN */
/*
* Output functions
*
*/
extern "C" void Prueba_Outputs_wrapper(real_T *y0,
const real_T *xD)
{
/* %%%-SFUNWIZ_wrapper_Outputs_Changes_BEGIN --- EDIT HERE TO _END */
if (xD[0] == 1){
# ifndef MATLAB_MEX_FILE
float pressure = LPS::readPressureMillibars();
float altitude = LPS::pressureToAltitudeMeters(pressure);
float temperature = LPS::readTemperatureC();
Serial.print("p: ");
Serial.print(pressure);
Serial.print(" mbar\ta: ");
Serial.print(altitude);
Serial.print(" m\tt: ");
Serial.print(temperature);
Serial.println(" deg C");
# endif
}
/* %%%-SFUNWIZ_wrapper_Outputs_Changes_END --- EDIT HERE TO _BEGIN */
}
/*
* Updates function
*
*/
extern "C" void Prueba_Update_wrapper(real_T *y0,
real_T *xD)
{
/* %%%-SFUNWIZ_wrapper_Update_Changes_BEGIN --- EDIT HERE TO _END */
if (xD[0] != 1){
# ifndef MATLAB_MEX_FILE
Serial.begin(9600);
Wire.begin();
if (!ps.init())
{
Serial.println("Failed to autodetect pressure sensor!");
while (1);
}
ps.enableDefault();
# endif
xD[0] = 1;
}
/* %%%-SFUNWIZ_wrapper_Update_Changes_END --- EDIT HERE TO _BEGIN */
}
Can someone help to fin the error?
Thanks

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Modeling 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by