Error: request for member 'BLANK' in '* BLANK', which is of non-class type 'real_T {aka double}'

8 views (last 30 days)
Hello everyone!
I am having some issues trying to get my GPS code (written in arduino) to work with an S-Function made in Simulink. The error I am getting is on many of the pointers that are defined in the header files. Hopefully you'll know what I mean when you see the code and the error. I have the GPS connected to the Arduino Mega via the serial RX and TX pin and it does work when ran in the Arduino IDE.
Here is the Code in the wrapper.cpp file that I have written.
if true
% code
end
if true
/*
* 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 <Wire.h>
#include <Wire.cpp>
#include <twi.c>
#include <twi.h>
#include "Adafruit_GPS.h"
#include "Adafruit_GPS.cpp"
#include <SoftwareSerial.h>
#include <SoftwareSerial.cpp>
bool blinkState = false;
int CHANNEL = 30; //Channel Pin
Adafruit_GPS GPS(&Serial1);
HardwareSerial mySerial = Serial1; //GPS TX to MEGA RX1, GPS RX to MEGA TX1
#define GPSECHO false
// this keeps track of whether we're using the interrupt
// off by default!
boolean usingInterrupt = false;
void useInterrupt(boolean); // Func prototype keeps Arduino happy
SIGNAL(TIMER0_COMPA_vect) {
char c = GPS.read();
// if you want to debug, this is a good time to do it!
#ifdef UDR0
if (GPSECHO)
if (c) UDR0 = c;
// writing direct to UDR0 is much much faster than Serial.print
// but only one character can be written at a time.
#endif
}
void useInterrupt(boolean v) {
if (v) {
// Timer0 is already used for millis() - we'll just interrupt somewhere
// in the middle and call the "Compare A" function above
OCR0A = 0xAF;
TIMSK0 |= _BV(OCIE0A);
usingInterrupt = true;
} else {
// do not call the interrupt function COMPA anymore
TIMSK0 &= ~_BV(OCIE0A);
usingInterrupt = false;
}
}
#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 function
*
*/
extern "C" void Receiver_GPS_Test_Block_Outputs_wrapper(real_T *PILOT_CMD,
real_T *GPS,
const real_T *xD,
const boolean_T *LED_PIN, const int_T p_width0,
const boolean_T *IND, const int_T p_width1)
{
/* %%%-SFUNWIZ_wrapper_Outputs_Changes_BEGIN --- EDIT HERE TO _END */
if(xD[0] == 1){
#ifndef MATLAB_MEX_FILE
digitalWrite(LED_PIN[0], blinkState);
blinkState = !blinkState;
PILOT_CMD[0] = pulseIn(CHANNEL, HIGH, 25000);
uint32_t timer = millis();
//Serial.println("15000");
//delay(100);
// in case you are not using the interrupt above, you'll
// need to 'hand query' the GPS, not suggested :(
if (! usingInterrupt) {
// read data from the GPS in the 'main loop'
char c = GPS->read();
// if you want to debug, this is a good time to do it!
if (GPSECHO)
if (c) Serial.print(c);
}
// if a sentence is received, we can check the checksum, parse it...
if (GPS.newNMEAreceived()) {
// a tricky thing here is if we print the NMEA sentence, or data
// we end up not listening and catching other sentences!
// so be very wary if using OUTPUT_ALLDATA and trytng to print out data
//Serial.println(GPS.lastNMEA()); // this also sets the newNMEAreceived() flag to false
if (!GPS.parse(GPS.lastNMEA())) // this also sets the newNMEAreceived() flag to false
return; // we can fail to parse a sentence in which case we should just wait for another
}
// if millis() or timer wraps around, we'll just reset it
if (timer > millis()) timer = millis();
// approximately every 2 seconds or so, print out the current stats
if (millis() - timer > 1000) {
timer = millis(); // reset the timer
GPS[0] = GPS.latitudeDegrees;
GPS[1] = GPS.longitudeDegrees;
}
#endif
}
/* %%%-SFUNWIZ_wrapper_Outputs_Changes_END --- EDIT HERE TO _BEGIN */
}
/*
* Updates function
*
*/
extern "C" void Receiver_GPS_Test_Block_Update_wrapper(real_T *PILOT_CMD,
real_T *GPS,
real_T *xD,
const boolean_T *LED_PIN, const int_T p_width0,
const boolean_T *IND, const int_T p_width1)
{
/* %%%-SFUNWIZ_wrapper_Update_Changes_BEGIN --- EDIT HERE TO _END */
if (xD[0] == 0){
#ifndef MATLAB_MEX_FILE
Serial.begin(115200); // connect at 115200 so we can read the GPS fast enough and echo without dropping chars
GPS.begin(9600); // 9600 NMEA is the default baud rate for Adafruit MTK GPS's- some use 4800
Wire.begin();
pinMode(LED_PIN[0], OUTPUT);
pinMode(IND[0], OUTPUT);
pinMode(CHANNEL, INPUT); //Receiver input
GPS.sendCommand(PMTK_SET_NMEA_OUTPUT_RMCGGA);
GPS.sendCommand(PMTK_SET_NMEA_UPDATE_10HZ); // 10 Hz update rate (for some reason needs debug
useInterrupt(true);
// Initialization LED
digitalWrite(IND[0], HIGH);
#endif
xD[0] = 1;
}
/* %%%-SFUNWIZ_wrapper_Update_Changes_END --- EDIT HERE TO _BEGIN */
}
end
The error I get is as follows.
if true
% code
../Receiver_GPS_Test_Block_wrapper.cpp:108:19: error: request for member 'read' in '* GPS', which is of non-class type 'real_T {aka double}'
char c = GPS->read();
^
../Receiver_GPS_Test_Block_wrapper.cpp:115:11: error: request for member 'newNMEAreceived' in 'GPS', which is of non-class type 'real_T* {aka double*}'
if (GPS.newNMEAreceived()) {
^
../Receiver_GPS_Test_Block_wrapper.cpp:121:14: error: request for member 'parse' in 'GPS', which is of non-class type 'real_T* {aka double*}'
if (!GPS.parse(GPS.lastNMEA())) // this also sets the newNMEAreceived() flag to false
^
../Receiver_GPS_Test_Block_wrapper.cpp:121:24: error: request for member 'lastNMEA' in 'GPS', which is of non-class type 'real_T* {aka double*}'
if (!GPS.parse(GPS.lastNMEA())) // this also sets the newNMEAreceived() flag to false
^
../Receiver_GPS_Test_Block_wrapper.cpp:153:20: error: request for member 'latitudeDegrees' in 'GPS', which is of non-class type 'real_T* {aka double*}'
GPS[0] = GPS.latitudeDegrees;
^
../Receiver_GPS_Test_Block_wrapper.cpp:154:20: error: request for member 'longitudeDegrees' in 'GPS', which is of non-class type 'real_T* {aka double*}'
GPS[1] = GPS.longitudeDegrees;
^
../Receiver_GPS_Test_Block_wrapper.cpp: In function 'void Receiver_GPS_Test_Block_Update_wrapper(real_T*, real_T*, real_T*, const boolean_T*, int_T, const boolean_T*, int_T)':
../Receiver_GPS_Test_Block_wrapper.cpp:187:9: error: request for member 'begin' in 'GPS', which is of non-class type 'real_T* {aka double*}'
GPS.begin(9600); // 9600 NMEA is the default baud rate for Adafruit MTK GPS's- some use 4800
^
../Receiver_GPS_Test_Block_wrapper.cpp:194:9: error: request for member 'sendCommand' in 'GPS', which is of non-class type 'real_T* {aka double*}'
GPS.sendCommand(PMTK_SET_NMEA_OUTPUT_RMCGGA);
^
../Receiver_GPS_Test_Block_wrapper.cpp:195:9: error: request for member 'sendCommand' in 'GPS', which is of non-class type 'real_T* {aka double*}'
GPS.sendCommand(PMTK_SET_NMEA_UPDATE_10HZ); // 10 Hz update rate (for some reason needs debug
^
end
Can anyone help me with this issue? I cant seem to see the problem as the code works completely fine in the arduino IDE (with a few changes) but nothing that pertains to the error at hand.
Thanks!

Answers (1)

Walter Roberson
Walter Roberson on 26 Aug 2018
You are telling C that you are passing a pointer to real_t under the name GPS, but you then try to use GPS as if it pointed to a structure. If the actual value passed is a pointer to a structure then you should say so in the function definition.

Categories

Find more on Arduino Hardware 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!