Stray '\' Error

// Reads serial 1,2,3 will stopa at \r and replace it with \0
void readSerial123(){
motorTimeout=millis() + MOTOR_TIMEOUT;
// Read answers
// Read Serial1
i=0;
while(1){
m1str*=Serial1.read();*
if(m1str*==’\r’)*
{
m1str*=’\0’;*
break;
}
if(m1str*!=-1){*
* i++;*
}
else if(millis()>motorTimeout){
if(PRINT_STATUS){
Serial.println(“ERROR: M1”);
}
m1str*=’\0’; // Keep old value FIX!!*
break;
}
}
// Read Serial2
i=0;
while(1){
m2str*=Serial2.read();*
if(m2str*==’\r’){*
_ m2str*=’\0’;
break;
}_

_if(m2str!=-1){
i++;
}
else if(millis()>motorTimeout){
if(PRINT_STATUS){
Serial.println(“ERROR: M2”);
}_

_m2str=’\0’; // Keep old value FIX!!
break;
}
}
// Read Serial3*

i=0;
while(1){
m3str*=Serial3.read();*
if(m3str*==’\r’){*
m3str*=’\0’;*
break;
}
if(m3str*!=-1){*
i++;
}
else if(millis()>motorTimeout){
if(PRINT_STATUS){
Serial.println(“ERROR: M3”);
}
m3str*=’\0’; // Keep old value FIX!!*
break;
}
}
}
Hi
am getting error: stray ‘’ in program in tis program
Any suggestions on how I can fix these errors_

There's a really good reason we ask you to post code in code tags.
Thanks for the demonstration.

(You probably cut and pasted your code from a web page. Paste it into a good editor, select hex display, and delete anything that doesn't look like ASCII)

That code snippet uses a load of variables which look as if they should be locals, which aren't declared.

The way you're detecting the motor timeout does not handle timer rollover safely. To be safe, you should use subtraction rather than addition, and use unsigned variables. I guess this sketch won't run long enough for that to be an issue, but you should get in the habit of doing it correctly anyway.

You could avoid having to test whether you actually received a character from the serial port (returned value -1) by only reading when available() returns a positive value. This would make your serial port buffering code less obtuse.

Since you apply the same logic to three serial ports, you should factor it out into a function to eliminate the code duplication.

The 'while' loop logic would IMO be clearer by replacing the while(1) infinite loops with loops that explicitly check the termination conditions i.e. end of line or timeout. Obviously they are not really infinite loop, and the control structure would be simpler and clearer if you used the loop statement to achieve that, rather than hiding it in the body of the loop.

You need to replace all the ’ characters with ' characters.