Add a check and counter if printer is heating

to avoid to go in long loop when sending command
This commit is contained in:
Luc 2016-12-04 17:13:42 +01:00
parent 74b9516ccc
commit 99578de542
3 changed files with 15 additions and 10 deletions

View File

@ -484,12 +484,13 @@ void COMMAND::execute_command(int cmd,String cmd_params, tpipe output)
}
}
void COMMAND::check_command(String buffer, tpipe output, bool handlelockserial)
bool COMMAND::check_command(String buffer, tpipe output, bool handlelockserial)
{
String buffer2;
LOG("Check Command:")
LOG(buffer)
LOG("\r\n")
bool is_temp = false;
//feed the WD for safety
delay(0);
//if direct access to SDCard no need to handle the M20 command answer
@ -512,12 +513,11 @@ void COMMAND::check_command(String buffer, tpipe output, bool handlelockserial)
web_interface->fileslist.clear();
//block any new output to serial from ESP to avoid pollution
if (handlelockserial)(web_interface->blockserial) = true;
return;
return is_temp;
}
#endif
#ifdef TEMP_MONITORING_FEATURE
int Tpos = buffer.indexOf("T:");
#endif
if (Tpos > -1 ) is_temp = true;
#ifdef POS_MONITORING_FEATURE
int Xpos = buffer.indexOf("X:");
int Ypos = buffer.indexOf("Y:");
@ -673,6 +673,7 @@ void COMMAND::check_command(String buffer, tpipe output, bool handlelockserial)
}
}
#endif
return is_temp;
}
//read a buffer in an array

View File

@ -31,7 +31,7 @@ public:
static void read_buffer_serial(uint8_t *b, size_t len);
static void read_buffer_serial(uint8_t b);
static void read_buffer_tcp(uint8_t b);
static void check_command(String buffer, tpipe output, bool handlelockserial = true);
static bool check_command(String buffer, tpipe output, bool handlelockserial = true);
static void execute_command(int cmd,String cmd_params, tpipe output);
static String get_param(String & cmd_params, const char * id, bool withspace = false);
static bool isadmin(String & cmd_params);

View File

@ -3803,10 +3803,11 @@ void handle_web_command(){
String current_buffer;
String current_line;
int pos;
int temp_counter = 0;
String tmp;
bool datasent = false;
//pickup the list
while (count < MAX_TRY){
//pickup the list
while (count < MAX_TRY){
//give some time between each buffer
if (Serial.available()){
count = 0;
@ -3836,7 +3837,7 @@ void handle_web_command(){
LOG(current_line)
LOG("\r\n")
//check command
COMMAND::check_command(current_line, NO_PIPE, false);
if (COMMAND::check_command(current_line, NO_PIPE, false)) temp_counter ++ ;
#if ((FIRMWARE_TARGET == REPETIER) || (FIRMWARE_TARGET == REPETIER4DV))
if (!current_line.startsWith( "ok "))
#endif
@ -3853,11 +3854,14 @@ void handle_web_command(){
tmp = current_buffer.substring(current_buffer.indexOf("\n")+1,current_buffer.length());
current_buffer = tmp;
}
delay (0);
} else delay(1);
//it is sending too many temp status should be heating so let's exit the loop
if (temp_counter > 5)count = MAX_TRY;
count++;
}
//to be sure connection close
if (buffer2send.length() > 0) {
//to be sure connection close
if (buffer2send.length() > 0) {
web_interface->WebServer.sendContent(buffer2send);
datasent = true;
}