This i my new try of sending file from master to a slave.
Master :
#include <Wire.h>
#include <I2C_Anything.h>
const byte SLAVE_ADDRESS = 0x1;
void setup()
{
Serial.begin(9600);
Wire.begin ();
} // end of setup
void loop()
{
long foo = 42;
float bar = 123.456;
Wire.beginTransmission (SLAVE_ADDRESS);
I2C_writeAnything (foo);
I2C_writeAnything (bar);
Wire.endTransmission();
} // end of loop
Slave:
#include <Wire.h>
#include <I2C_Anything.h>
#define SLAVE_ADDRESS 0x1
void setup()
{
Serial.begin(9600);
Wire.begin (SLAVE_ADDRESS);
Wire.onReceive (receiveEvent); // interrupt handler for incoming messages
} // end of setup
void loop()
{
} // end of loop
volatile boolean haveData = false;
volatile long foo;
volatile float bar;
// called by interrupt service routine when incoming data arrives
void receiveEvent (int howMany)
{
if (howMany >= (sizeof foo) + (sizeof bar))
{
I2C_readAnything (foo);
I2C_readAnything (bar);
haveData = true;
} // end if have enough data
} // end of receiveEvent
It looks like the Master receives the file but it can't transmit it to the slave.