Add a uart RX timeout
This commit is contained in:
parent
42ac9c0ec3
commit
ed8252527c
@ -24,8 +24,7 @@ int serial_count = 0; //index of character read from serial line
|
|||||||
bool comment_mode = false;
|
bool comment_mode = false;
|
||||||
char *strchr_pointer; // just a pointer to find chars in the command string like X, Y, Z, E, etc
|
char *strchr_pointer; // just a pointer to find chars in the command string like X, Y, Z, E, etc
|
||||||
|
|
||||||
unsigned long TimeSent = _millis();
|
ShortTimer serialTimeoutTimer;
|
||||||
unsigned long TimeNow = _millis();
|
|
||||||
|
|
||||||
long gcode_N = 0;
|
long gcode_N = 0;
|
||||||
long gcode_LastN = 0;
|
long gcode_LastN = 0;
|
||||||
@ -400,8 +399,7 @@ void get_command()
|
|||||||
MYSERIAL.write(serial_char); // for debuging serial line 2 in farm_mode
|
MYSERIAL.write(serial_char); // for debuging serial line 2 in farm_mode
|
||||||
selectedSerialPort = 1;
|
selectedSerialPort = 1;
|
||||||
} */ //RP - removed
|
} */ //RP - removed
|
||||||
TimeSent = _millis();
|
serialTimeoutTimer.start();
|
||||||
TimeNow = _millis();
|
|
||||||
|
|
||||||
if (serial_char < 0)
|
if (serial_char < 0)
|
||||||
// Ignore extended ASCII characters. These characters have no meaning in the G-code apart from the file names
|
// Ignore extended ASCII characters. These characters have no meaning in the G-code apart from the file names
|
||||||
@ -535,23 +533,12 @@ void get_command()
|
|||||||
}
|
}
|
||||||
} // end of serial line processing loop
|
} // end of serial line processing loop
|
||||||
|
|
||||||
if(farm_mode){
|
if (serial_count > 0 && serialTimeoutTimer.expired(farm_mode ? 800 : 2000)) {
|
||||||
TimeNow = _millis();
|
comment_mode = false;
|
||||||
if ( ((TimeNow - TimeSent) > 800) && (serial_count > 0) ) {
|
|
||||||
cmdbuffer[bufindw+serial_count+CMDHDRSIZE] = 0;
|
|
||||||
|
|
||||||
bufindw += strlen(cmdbuffer+bufindw+CMDHDRSIZE) + (1 + CMDHDRSIZE);
|
|
||||||
if (bufindw == sizeof(cmdbuffer))
|
|
||||||
bufindw = 0;
|
|
||||||
++ buflen;
|
|
||||||
|
|
||||||
serial_count = 0;
|
serial_count = 0;
|
||||||
|
SERIAL_ECHOLNPGM("RX timeout");
|
||||||
SERIAL_ECHOPGM("TIMEOUT:");
|
|
||||||
//memset(cmdbuffer, 0 , sizeof(cmdbuffer));
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef SDSUPPORT
|
#ifdef SDSUPPORT
|
||||||
if(!card.sdprinting || serial_count!=0){
|
if(!card.sdprinting || serial_count!=0){
|
||||||
|
@ -52,9 +52,6 @@ extern int serial_count;
|
|||||||
extern bool comment_mode;
|
extern bool comment_mode;
|
||||||
extern char *strchr_pointer;
|
extern char *strchr_pointer;
|
||||||
|
|
||||||
extern unsigned long TimeSent;
|
|
||||||
extern unsigned long TimeNow;
|
|
||||||
|
|
||||||
extern long gcode_N;
|
extern long gcode_N;
|
||||||
extern long gcode_LastN;
|
extern long gcode_LastN;
|
||||||
extern long Stopped_gcode_LastN;
|
extern long Stopped_gcode_LastN;
|
||||||
|
Loading…
Reference in New Issue
Block a user