Hi every one
Hereafter the error message that I do not understand.
Someone could help me please ?
Thanks in advance for any comment and/or correction.
There is the error message and the relative code to this error :
The error during compilation :
Packet.cpp:140:45: error: cannot call member function 'void I2C_Command::I2C_SendData(int, int, int*) volatile' without object
I2C_Command::I2C_SendData(2, 1, *dataToI2C[]) volatile ;
The code : (there are 3 parts)
1st part - In I2C_Command .h file :
#include "Arduino.h"
#ifndef I2C_Command_h
#define I2C_Command_h
struct I2C_Command {
static void I2C_Scan();
void I2C_SendData(int, int, int[]) ;
void I2C_Request(int, int, int[]);
}; // I2C_Command
#endif
2nd part - In I2C_Command.cpp file :
// Library
//#include <Wire.h>
//////////////////////////////////////////////////////////////////////////
#include "I2C_Command.h"
///////////////////////////////////////////////////////////////////////////////
void I2C_Command::I2C_SendData(int I2Cadr, int I2Clenght, int I2Cdata[]) {
Wire.beginTransmission(I2Cadr); // transmit to device #2
for (int i = 0; i <= I2Clenght; ++i) {
Wire.write(I2Cdata[i]); // sends one byte
}
Wire.endTransmission(); // stop transmitting
Serial.println(I2Clenght + "I2C sent");
for (int i = 0; i <= I2Clenght; ++i) {
Serial.print(I2Cdata[i]); // sends one byte
}
Serial.println();
}
///////////////////////////////////////////////////////////////////////////////
void I2C_Command::I2C_Request(int I2Cadr, int I2Clenght, int I2Cdata[]) {
Wire.requestFrom(I2Cadr, I2Clenght); // request int from slave device #8
for (int i = 0; i < I2Clenght; ++i) {
while (Wire.available()) { // slave may send less than requested
I2Cdata[i] = Wire.read();
}
}
}
3rd part - In Packet.cpp file :
#include "Packet.h"
#include "I2C_Command.h"
///////////////////////////////////////////////////////////////////////////////
void PacketList::set(char *s) volatile {
byte b[5]; // save space for checksum byte
int nR;
int tC;
int tS;
int tD;
int dataToI2C[20];
if (sscanf(s, "%d %d %d %d", &nR, &tC, &tS, &tD) != 4)
return;
dataToI2C[0] = '1';
I2C_Command::I2C_SendData(2, 1, dataToI2C) ;
} // PacketList::set()