I know ! and it is really bad. I want domi1 to write normal code that he needs instead of copying code that he does not need.
I think that this makes more sense (not that I'm totally happy with it):
void receiveEvent(int nBytes)
{
int i;
if (nBytes > 2) // at least 2
{
command = Wire.read();
commandLength = Wire.read();
if( commandLength < BUFFER_SIZE) // reserve one for zero-terminator
{
for (i=0; i<commandLength; i++)
{
commandBuffer[i] = Wire.read();
}
commandBuffer[i] = '\0';
printRequest = 1;
}
}
}
[EDIT] Changed the code, added BUFFER_SIZE.