Arduino read string

hallo, i has facing some problem. Refer to my programming at below, when the arduino receive '@', the arduino will tx bck to 0x40,0x30,0x31and 0x06. how to write that to let the arduino able to receive @01T and than tx bck to 0x40,0x30,0x31and 0x06?

void online(void); void setup() { // Open serial communications and wait for port to open: Serial.begin(9600); }

void loop() {

if(Serial.available()>0) { char inChar = (char)Serial.read();

if(inChar=='@') { online(); }

} }

void online() { Serial.write(0x40); //@ Serial.write(0x30); //0 Serial.write(0x31); //1 Serial.write(0x06); //ACK }

Two ways come to mind

Read each character from serial until the input is complete, adding each received character to an array of chars terminated by '\0'. When the input is complete test the whole string against @01T and respond if there is a match. See http://www.gammon.com.au/forum/bbshowpost.php?bbsubject_id=11425&page=1

Read each character from serial and compare it with the next one expected. Keep going until you have read and matched 4 characters successfully. This is less elegant and of less general use as a technique.

In either case you need to allow for the receipt of a string/char that does not match the expected input and resest the program to start recieving again.