Serial protocol: read from RS-232 and write to EEPROM

Hi, my app needs to store data in Arduino integrated EEPROM.
I need to create simple communication protocol - I need 2 function: dump EEPROM over RS-232 to PC and read data from PC and save it to EEPROM.

There is my code:

#include <EEPROM.h>

byte inData[512];
int inDataCount = 0;

void setup () {
  Serial.begin(9600);  
  Serial.println(F("\nStart!"));
}

void loop () {
 if (Serial.available() > 0) {
   if (Serial.find("@") ) {
     dumpSettings();
   }
   while (Serial.find("#")) {
     Serial.println(F("start reading:"));
     byte incomingByte = Serial.read();
     if ( (incomingByte == '

If I send "@", Arduino dump EEPROM to PC. But I can't write EEPROM from PC.
What I do bad?) && (inDataCount > 10) ) {
      writeSettings(inData);
      Serial.println(F("eeprom written"));
    } else {   
      inData[inDataCount] = incomingByte;
      inDataCount++; 
    } 
  } 
}

}

static void dumpSettings() {
  Serial.println(F(""));
  for (int i=0; i<512; i++) {
    Serial.print(i);
    Serial.print(F(" = "));
    byte value = EEPROM.read(i);
    Serial.print(value); // Serial.print(value, HEX); DEC HEX OCT BIN
    Serial.print("\n");
  }
  Serial.println(F("
"));
}

static void writeSettings(byte stringToWrite[]) {
  Serial.println(F(""));
  clearEEPROM();
  for (int i=0; i<512; i++) {
    byte value = stringToWrite[i];
    EEPROM.write(i, value);
    Serial.print(i);
    Serial.print(F(" = "));
    Serial.println(stringToWrite[i]);
  }
  Serial.println(F("
"));
}

static void clearEEPROM() {
  for (int i = 0; i < 512; i++) {
    EEPROM.write(i, '\0');
  }
}


If I send "@", Arduino dump EEPROM to PC. But I can't write EEPROM from PC.
What I do bad?

The Serial.find() is a very blunt instrument. I don't use it as it isn't usually the right instrument for what I'm trying to do.

You are finding the "#" in the incoming datastream and then reading the next character into your incomingByte. Then you expect to go around the loop and read more characters but your loop condition tries to find ANOTHER "#" so it ignores the other data.

You need another loop inside that. Maybe something like this will work:

 if (Serial.find("#")) {
   while(Serial.peek()!="#" && Serial.peek()!="@") { //keep looping until we find a special character (we have failed to find the correct end-of-data character
     Serial.println(F("start reading:"));
     byte incomingByte = Serial.read();
     if ( (incomingByte == '

) && (inDataCount > 10) ) {
      writeSettings(inData);
      Serial.println(F("eeprom written"));
      break; //leave the loop here
    } else {   
      inData[inDataCount] = incomingByte;
      inDataCount++; 
    } 
  } 
  }

The examples in serial input basics illustrate a simple and robust way to receive data

...R