Hi!
I am communicating between PC and Arduino using your messenger protocol and so far it is great. But now I am trying to send a whole text-array and found something strange:
Whenever I send a message from PC to Arduino that has 64 or more characters the message gets lost. Just so you can have some fun looking at my 'totally awesome' coding skills, here is what I'm using:
void messageCompleted() {
// This loop will echo each element of the message separately
byte i;
byte j;
while ( message.available() ) {
message.copyString(MsgrString,MAXSIZE);
// Serial.print(MsgrString); // Echo the string
// Serial.println(); // Terminate the message with a carriage return
if (!strcmp(MsgrString,"?")) { // Somebody wants us to SEND data
while ( message.available() ) {
message.copyString(MsgrString,MAXSIZE);
// Serial.print(MsgrString); // Echo the string
// Serial.println(); // Terminate the message with a carriage return
if (!strcmp(MsgrString,"RoomName")) { // We need to send the RoomName array
//Serial.println("Sending RoomName array");
for (i=0; i<8; i++){
//Serial.print(i, DEC);
Serial.print(RoomName[i]);
Serial.print(" ");
}
Serial.println();
}
if (!strcmp(MsgrString,"Mode")) { // We need to send the Mode byte
//Serial.println("Sending Mode");
Serial.print("Mode=");
Serial.println(Mode, DEC);
}
}
}
if (!strcmp(MsgrString,"!")) { // Somebody wants us to RECEIVE data
while ( message.available() ) {
message.copyString(MsgrString,MAXSIZE);
//Serial.print(MsgrString); // Echo the string
//Serial.println(); // Terminate the message with a carriage return
if (!strcmp(MsgrString,"RoomName")) { // We need to receive the RoomName array
//Serial.println("Receiving RoomName array");
i=0;
while ( message.available() ) {
message.copyString(MsgrString,MAXSIZE);
//Serial.print(MsgrString); // Echo the string
//Serial.println(); // Terminate the message with a carriage return
for (j=0; j<10; j++){
RoomName[i][j] = MsgrString[j];
}
Serial.print(i, DEC);
//Serial.println(RoomName[i]);
i++;
}
Serial.println("RoomName array:");
for (i=0; i<8; i++){
Serial.print(i, DEC);
Serial.print(" ");
//Serial.println(RoomName[i]);
}
}
else if (!strcmp(MsgrString,"Mode")) { // We need to receive the Mode byte
while ( message.available() ) {
Serial.println("receiving Mode");
Mode = message.readInt();
Serial.print("I received: ");
Serial.println(Mode, DEC);
}
}
}
}
}
Is there a 64 character limitation? Or is the problem somehow on my side?
BTW: MAXSIZE is 255.
Thanks for a great library!
Stefan