From 3d92f78eca42a6062bbe68a6770fc9297220192d Mon Sep 17 00:00:00 2001 From: luc lebosse Date: Wed, 29 Jun 2016 18:42:00 +0200 Subject: [PATCH] Fix SD File listing incomplete as still processing Separate M20 command from file listing to give time to get the complete file list before sending the list Change SDK function system_get_time and wifi_get_opmode to use wrapper ones and avoid to include user_interface.h if not necessary --- esp3d/command.cpp | 19 ++++++----- esp3d/data/printer.tpl | 23 ++++++++++--- esp3d/webinterface.cpp | 76 +++++++++++++++++++++++------------------- 3 files changed, 71 insertions(+), 47 deletions(-) diff --git a/esp3d/command.cpp b/esp3d/command.cpp index 010c1c91..41377ac1 100644 --- a/esp3d/command.cpp +++ b/esp3d/command.cpp @@ -22,9 +22,6 @@ #include "config.h" #include "wifi.h" #include "webinterface.h" -extern "C" { -#include "user_interface.h" -} String COMMAND::buffer_serial; String COMMAND::buffer_tcp; @@ -81,7 +78,7 @@ void COMMAND::execute_command(int cmd,String cmd_params) break; case 111: { String currentIP ; - if (wifi_get_opmode()==WIFI_STA) { + if (WiFi.getMode()==WIFI_STA) { currentIP=WiFi.localIP().toString(); } else { currentIP=WiFi.softAPIP().toString(); @@ -141,7 +138,7 @@ void COMMAND::check_command(String buffer) //yes it is file list starting to be displayed if (filesstart>-1) { //init time out - start_list=system_get_time(); + start_list = millis(); //set file list started bfileslist=true; //clear current list @@ -198,7 +195,7 @@ void COMMAND::check_command(String buffer) //if match mask T:xxx.xx /xxx.xx if(spacepos-Tpos < 17) { web_interface->answer4M105=buffer; //do not interprete just need when requested so store it - web_interface->last_temp=system_get_time(); + web_interface->last_temp=millis(); } } //Position of axis @@ -248,18 +245,24 @@ void COMMAND::check_command(String buffer) } } else { //listing file is on going //check if we are too long - if ((system_get_time()-start_list)>30000000) { //timeout in case of problem + if ((millis()-start_list)>30000) { //timeout in case of problem bfileslist=false; (web_interface->blockserial) = false; //release serial + LOG("Time out\n"); } else { //check if this is the end if (buffer.indexOf("End file list")>-1) { bfileslist=false; (web_interface->blockserial) = false; + LOG("End list\n"); } else { //Serial.print(buffer); //add list to buffer web_interface->fileslist.add(buffer); + LOG(String(web_interface->fileslist.size())); + LOG(":"); + LOG(buffer); + LOG('\n'); } } @@ -315,7 +318,7 @@ void COMMAND::read_buffer_serial(uint8_t b) previous_was_char=false; //next call will reset the buffer } //this is not printable but end of command check if need to handle it - if (b==13 ||b==10) { + if (b==13) { //Minimum is something like M10 so 3 char if (buffer_serial.length()>3) { check_command(buffer_serial); diff --git a/esp3d/data/printer.tpl b/esp3d/data/printer.tpl index 08bd5d26..6433d771 100644 --- a/esp3d/data/printer.tpl +++ b/esp3d/data/printer.tpl @@ -65,7 +65,7 @@ $INCLUDE[css2.inc]$ - + SD    @@ -351,13 +351,21 @@ Sendcommand("M23 " + filename); delay(100); Sendcommand("M24");} } - +var retry = 0; function refreshfilelist(jsonresponse){ + var list2display="