So this works:
char masterMessage[20];///
int msgLength = 0;
boolean IsMessage=false;
boolean done;
void setup()
{
Serial.begin(19200);
}
void loop()
{
if (Serial.available() >8){ // enough data arrived?
done=false;
if (Serial.read() == '
Output attached for this string
$A,-3,72,F,1#
entered into the serial terminal.
Can you tell me why it seems a bit fussy, and I had to add the delay to make it work?
It was printing back some odd characters...
){ // correct start byte?while (done != true) {
masterMessage[msgLength] = Serial.read();
delay(10);
if (masterMessage[msgLength] == '#'){done=true;}
msgLength=msgLength++;
}
}
IsMessage=true;
} // end data available check
if (IsMessage){
for (int i=0;i<msgLength;i=i++){
Serial.println(masterMessage[i],DEC);
}
Serial.println(" ");
IsMessage = false;
}
msgLength = 0;
}
Output attached for this string
$A,-3,72,F,1#
entered into the serial terminal.
Can you tell me why it seems a bit fussy, and I had to add the delay to make it work?
It was printing back some odd characters...



