Hi community,
I'm trying to pass a struct to a class function as a call by reference.
With a array it's working fine, with a struct I get a error message, can't understand.
Basically it's a LIN Slave Class but I stripped it down to the porblem ...
I want to pass several arguments and additional a array that will be filled with the message comming from the LIN line.
the main:
#include "Arduino.h"
#include "lin.h"
Lin lin_1;
uint8_t msg_eingang_slave[8] = { 0 };
uint8_t msg_eingang_schalter[8] = { 0 };
uint8_t test_msg[8] = {0};
struct std_lin_save
{
uint8_t msg_id;
uint8_t proto; // std LIN = 2 Lin diag = 1
uint8_t nBytes; // anzahl bytes im Array
boolean msg_request;
uint8_t* message;
};
struct std_lin_save Nachrichten_slave[3] =
{
{0xC1,2,8, true,msg_eingang_schalter},
{0xC1,2,8, false,msg_eingang_slave},
{0x2F,2,4, false,test_msg}
};
void setup()
{
Serial.begin(115200);
Serial.println("Start ...");
lin_1.set_data(std_lin_save *Nachrichten_slave);
}
void loop()
{
delay(1000);
}
The LIN Class reduced:
#include <inttypes.h>
#include "Arduino.h"
#include <HardwareSerial.h>
#ifndef LIN_H
#define LIN_H
class Lin
{
protected:
struct std_lin_save
{
uint8_t msg_id;
uint8_t proto; // std LIN = 2 Lin diag = 1
uint8_t nBytes; // anzahl bytes im Array
boolean msg_request;
uint8_t* message;
};
public:
void set_data(struct std_lin_save *Nachrichten_slave){
Serial.print(Nachrichten_slave->nBytes);
}
};
#endif
The error message:
..\LIN_test.ino:34:30: error: expected primary-expression before '*' token
lin_1.set_data(std_lin_save *Nachrichten_slave);
Who can help what's wrong?