From 574e2d856ec1f80aab347c12afc6e7b7f1618d11 Mon Sep 17 00:00:00 2001 From: wurstnase Date: Thu, 16 Apr 2015 13:07:20 +0200 Subject: [PATCH 1/6] remove config --- Marlin/Marlin_main.cpp | 10 +++++++++- Marlin/language.h | 1 + 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/Marlin/Marlin_main.cpp b/Marlin/Marlin_main.cpp index 64d3d1f350..b66f900950 100644 --- a/Marlin/Marlin_main.cpp +++ b/Marlin/Marlin_main.cpp @@ -263,6 +263,7 @@ static millis_t max_inactive_time = 0; static millis_t stepper_inactive_time = DEFAULT_STEPPER_DEACTIVE_TIME * 1000L; millis_t print_job_start_ms = 0; ///< Print job start time millis_t print_job_stop_ms = 0; ///< Print job stop time +static millis_t last_command_time = 0; static uint8_t target_extruder; bool no_wait_for_cooling = true; bool target_direction; @@ -724,8 +725,15 @@ void get_command() { if (drain_queued_commands_P()) return; // priority is given to non-serial commands + millis_t ms = millis(); + + if (!MYSERIAL.available() && commands_in_queue == 0 && ms - last_command_time > 1000) { + SERIAL_ECHOLNPGM(MSG_WAIT); + last_command_time = ms; + } + while (MYSERIAL.available() > 0 && commands_in_queue < BUFSIZE) { - + last_command_time = ms; serial_char = MYSERIAL.read(); if (serial_char == '\n' || serial_char == '\r' || diff --git a/Marlin/language.h b/Marlin/language.h index ba5f3f700e..220f715e69 100644 --- a/Marlin/language.h +++ b/Marlin/language.h @@ -121,6 +121,7 @@ #define MSG_FREE_MEMORY " Free Memory: " #define MSG_PLANNER_BUFFER_BYTES " PlannerBufferBytes: " #define MSG_OK "ok" +#define MSG_WAIT "wait" #define MSG_FILE_SAVED "Done saving file." #define MSG_ERR_LINE_NO "Line Number is not Last Line Number+1, Last Line: " #define MSG_ERR_CHECKSUM_MISMATCH "checksum mismatch, Last Line: " From d69da22f7c81073432c3e8e6ce5355dd7f7d40e4 Mon Sep 17 00:00:00 2001 From: wurstnase Date: Thu, 16 Apr 2015 16:20:23 +0200 Subject: [PATCH 2/6] last_command_time inside get_command() --- Marlin/Marlin_main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/Marlin_main.cpp b/Marlin/Marlin_main.cpp index b66f900950..6cc0120817 100644 --- a/Marlin/Marlin_main.cpp +++ b/Marlin/Marlin_main.cpp @@ -263,7 +263,6 @@ static millis_t max_inactive_time = 0; static millis_t stepper_inactive_time = DEFAULT_STEPPER_DEACTIVE_TIME * 1000L; millis_t print_job_start_ms = 0; ///< Print job start time millis_t print_job_stop_ms = 0; ///< Print job stop time -static millis_t last_command_time = 0; static uint8_t target_extruder; bool no_wait_for_cooling = true; bool target_direction; @@ -725,6 +724,7 @@ void get_command() { if (drain_queued_commands_P()) return; // priority is given to non-serial commands + static millis_t last_command_time = 0; millis_t ms = millis(); if (!MYSERIAL.available() && commands_in_queue == 0 && ms - last_command_time > 1000) { From b09a957fcea37019356d4c679eb3d0e74446fe17 Mon Sep 17 00:00:00 2001 From: Wurstnase Date: Thu, 16 Apr 2015 21:42:54 +0200 Subject: [PATCH 3/6] make 'wait' optional and mark as workaround --- Marlin/Configuration_adv.h | 4 ++++ Marlin/Marlin_main.cpp | 18 +++++++++++------- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index 6478eb923e..c7a3de5f9a 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -374,6 +374,10 @@ const unsigned int dropsegments=5; //everything with less than this number of st #define MAX_CMD_SIZE 96 #define BUFSIZE 4 +// Some Hosts doesn't have a timeout for resend a command. +// This is a workaround for them. If your printer sometimes stuck and stop printing this could help. +// #define NO_TIMEOUTS + // @section fwretract // Firmware based and LCD controlled retract diff --git a/Marlin/Marlin_main.cpp b/Marlin/Marlin_main.cpp index 6cc0120817..9a9fe6086e 100644 --- a/Marlin/Marlin_main.cpp +++ b/Marlin/Marlin_main.cpp @@ -724,16 +724,20 @@ void get_command() { if (drain_queued_commands_P()) return; // priority is given to non-serial commands - static millis_t last_command_time = 0; - millis_t ms = millis(); + #ifdef NO_TIMEOUTS + static millis_t last_command_time = 0; + millis_t ms = millis(); - if (!MYSERIAL.available() && commands_in_queue == 0 && ms - last_command_time > 1000) { - SERIAL_ECHOLNPGM(MSG_WAIT); - last_command_time = ms; - } + if (!MYSERIAL.available() && commands_in_queue == 0 && ms - last_command_time > 1000) { + SERIAL_ECHOLNPGM(MSG_WAIT); + last_command_time = ms; + } + #endif while (MYSERIAL.available() > 0 && commands_in_queue < BUFSIZE) { - last_command_time = ms; + #ifdef NO_TIMEOUTS + last_command_time = ms; + #endif serial_char = MYSERIAL.read(); if (serial_char == '\n' || serial_char == '\r' || From 92575cecca064e18441dc40f3568b4f3706d203c Mon Sep 17 00:00:00 2001 From: Wurstnase Date: Mon, 20 Apr 2015 00:22:40 +0200 Subject: [PATCH 4/6] new timout/add adv_ok --- Marlin/Configuration_adv.h | 10 +++++++--- Marlin/Marlin_main.cpp | 8 ++++++-- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index c7a3de5f9a..f2b5c7dd26 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -374,9 +374,13 @@ const unsigned int dropsegments=5; //everything with less than this number of st #define MAX_CMD_SIZE 96 #define BUFSIZE 4 -// Some Hosts doesn't have a timeout for resend a command. -// This is a workaround for them. If your printer sometimes stuck and stop printing this could help. -// #define NO_TIMEOUTS +// Bad Serial-connections can miss a received command by sending an 'ok' +// Therefore some clients go after 30 seconds in a timeout. Some other clients start sending commands while receiving a 'wait'. +// This wait is only send when the buffer is empty. The timeout-length is in milliseconds. 1000 is a good value. +// #define NO_TIMEOUTS 1000 + +// Some clients will have this feature soon. This should make the NO_TIMEOUTS unnecessary. +// #define ADVANCED_OK // @section fwretract diff --git a/Marlin/Marlin_main.cpp b/Marlin/Marlin_main.cpp index 9a9fe6086e..4d915a2c7d 100644 --- a/Marlin/Marlin_main.cpp +++ b/Marlin/Marlin_main.cpp @@ -728,7 +728,7 @@ void get_command() { static millis_t last_command_time = 0; millis_t ms = millis(); - if (!MYSERIAL.available() && commands_in_queue == 0 && ms - last_command_time > 1000) { + if (!MYSERIAL.available() && commands_in_queue == 0 && ms - last_command_time > NO_TIMEOUTS) { SERIAL_ECHOLNPGM(MSG_WAIT); last_command_time = ms; } @@ -5299,7 +5299,11 @@ void ClearToSend() { #ifdef SDSUPPORT if (fromsd[cmd_queue_index_r]) return; #endif - SERIAL_PROTOCOLLNPGM(MSG_OK); + SERIAL_PROTOCOLPGM(MSG_OK); + #ifdef ADVANCED_OK + SERIAL_PROTOCOLPGM(" N"); SERIAL_PROTOCOL(gcode_LastN); + SERIAL_PROTOCOLPGM(" S"); SERIAL_PROTOCOLLN(commands_in_queue); + #endif } void get_coordinates() { From 0cb87795a30919b96aa4f098ace7ef7f84d6e7f7 Mon Sep 17 00:00:00 2001 From: Wurstnase Date: Fri, 8 May 2015 22:28:51 +0200 Subject: [PATCH 5/6] advanced 'ok' ok N(linenumber) P(bufferremaining) the host can use this to send the data much faster. Some pseudo code: If (bufferremaining > 0) send command ## as long there is free buffer send command Also if (linenumber > lastsend - bufferremaining) send command ## as long last linenumber received is bigger than lastsend (host) - last bufferremaining received --- Marlin/Marlin_main.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Marlin/Marlin_main.cpp b/Marlin/Marlin_main.cpp index 2319fe87fb..19bec369ba 100644 --- a/Marlin/Marlin_main.cpp +++ b/Marlin/Marlin_main.cpp @@ -5533,8 +5533,9 @@ void ClearToSend() { SERIAL_PROTOCOLPGM(MSG_OK); #ifdef ADVANCED_OK SERIAL_PROTOCOLPGM(" N"); SERIAL_PROTOCOL(gcode_LastN); - SERIAL_PROTOCOLPGM(" S"); SERIAL_PROTOCOLLN(commands_in_queue); + SERIAL_PROTOCOLPGM(" P"); SERIAL_PROTOCOL(BUFSIZE - commands_in_queue); #endif + SERIAL_PROTOCOLLNPGM(""); } void get_coordinates() { From 526ad82d20608d5262b5333684bcf7e85d18e431 Mon Sep 17 00:00:00 2001 From: Wurstnase Date: Mon, 11 May 2015 08:01:51 +0200 Subject: [PATCH 6/6] activate advanced_ok and no_timeout --- Marlin/Configuration_adv.h | 6 +++--- Marlin/Marlin_main.cpp | 2 +- Marlin/configurator/config/Configuration_adv.h | 8 ++++++++ .../example_configurations/Felix/Configuration_adv.h | 8 ++++++++ .../Hephestos/Configuration_adv.h | 10 +++++++++- .../example_configurations/K8200/Configuration_adv.h | 8 ++++++++ .../example_configurations/SCARA/Configuration_adv.h | 8 ++++++++ .../example_configurations/WITBOX/Configuration_adv.h | 10 +++++++++- .../delta/biv2.5/Configuration_adv.h | 8 ++++++++ .../delta/generic/Configuration_adv.h | 8 ++++++++ .../delta/kossel_mini/Configuration_adv.h | 8 ++++++++ .../example_configurations/makibox/Configuration_adv.h | 8 ++++++++ .../tvrrug/Round2/Configuration_adv.h | 8 ++++++++ 13 files changed, 94 insertions(+), 6 deletions(-) diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index ee390289b7..22ecc1d594 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -379,10 +379,10 @@ const unsigned int dropsegments=5; //everything with less than this number of st // Bad Serial-connections can miss a received command by sending an 'ok' // Therefore some clients go after 30 seconds in a timeout. Some other clients start sending commands while receiving a 'wait'. // This wait is only send when the buffer is empty. The timeout-length is in milliseconds. 1000 is a good value. -// #define NO_TIMEOUTS 1000 +#define NO_TIMEOUTS 1000 -// Some clients will have this feature soon. This should make the NO_TIMEOUTS unnecessary. -// #define ADVANCED_OK +// Some clients will have this feature soon. This could make the NO_TIMEOUTS unnecessary. +#define ADVANCED_OK // @section fwretract diff --git a/Marlin/Marlin_main.cpp b/Marlin/Marlin_main.cpp index 19bec369ba..62ac571403 100644 --- a/Marlin/Marlin_main.cpp +++ b/Marlin/Marlin_main.cpp @@ -5535,7 +5535,7 @@ void ClearToSend() { SERIAL_PROTOCOLPGM(" N"); SERIAL_PROTOCOL(gcode_LastN); SERIAL_PROTOCOLPGM(" P"); SERIAL_PROTOCOL(BUFSIZE - commands_in_queue); #endif - SERIAL_PROTOCOLLNPGM(""); + SERIAL_EOL; } void get_coordinates() { diff --git a/Marlin/configurator/config/Configuration_adv.h b/Marlin/configurator/config/Configuration_adv.h index b79035ab69..22ecc1d594 100644 --- a/Marlin/configurator/config/Configuration_adv.h +++ b/Marlin/configurator/config/Configuration_adv.h @@ -376,6 +376,14 @@ const unsigned int dropsegments=5; //everything with less than this number of st #define MAX_CMD_SIZE 96 #define BUFSIZE 4 +// Bad Serial-connections can miss a received command by sending an 'ok' +// Therefore some clients go after 30 seconds in a timeout. Some other clients start sending commands while receiving a 'wait'. +// This wait is only send when the buffer is empty. The timeout-length is in milliseconds. 1000 is a good value. +#define NO_TIMEOUTS 1000 + +// Some clients will have this feature soon. This could make the NO_TIMEOUTS unnecessary. +#define ADVANCED_OK + // @section fwretract // Firmware based and LCD controlled retract diff --git a/Marlin/example_configurations/Felix/Configuration_adv.h b/Marlin/example_configurations/Felix/Configuration_adv.h index 672b3ff028..a5e44e690d 100644 --- a/Marlin/example_configurations/Felix/Configuration_adv.h +++ b/Marlin/example_configurations/Felix/Configuration_adv.h @@ -376,6 +376,14 @@ const unsigned int dropsegments=5; //everything with less than this number of st #define MAX_CMD_SIZE 96 #define BUFSIZE 4 +// Bad Serial-connections can miss a received command by sending an 'ok' +// Therefore some clients go after 30 seconds in a timeout. Some other clients start sending commands while receiving a 'wait'. +// This wait is only send when the buffer is empty. The timeout-length is in milliseconds. 1000 is a good value. +#define NO_TIMEOUTS 1000 + +// Some clients will have this feature soon. This could make the NO_TIMEOUTS unnecessary. +#define ADVANCED_OK + // @section fwretract // Firmware based and LCD controlled retract diff --git a/Marlin/example_configurations/Hephestos/Configuration_adv.h b/Marlin/example_configurations/Hephestos/Configuration_adv.h index 5713373d16..3918fa53cb 100644 --- a/Marlin/example_configurations/Hephestos/Configuration_adv.h +++ b/Marlin/example_configurations/Hephestos/Configuration_adv.h @@ -374,7 +374,15 @@ const unsigned int dropsegments=5; //everything with less than this number of st //The ASCII buffer for receiving from the serial: #define MAX_CMD_SIZE 96 -#define BUFSIZE 5 +#define BUFSIZE 4 + +// Bad Serial-connections can miss a received command by sending an 'ok' +// Therefore some clients go after 30 seconds in a timeout. Some other clients start sending commands while receiving a 'wait'. +// This wait is only send when the buffer is empty. The timeout-length is in milliseconds. 1000 is a good value. +#define NO_TIMEOUTS 1000 + +// Some clients will have this feature soon. This could make the NO_TIMEOUTS unnecessary. +#define ADVANCED_OK // @section fwretract diff --git a/Marlin/example_configurations/K8200/Configuration_adv.h b/Marlin/example_configurations/K8200/Configuration_adv.h index 672b3ff028..a5e44e690d 100644 --- a/Marlin/example_configurations/K8200/Configuration_adv.h +++ b/Marlin/example_configurations/K8200/Configuration_adv.h @@ -376,6 +376,14 @@ const unsigned int dropsegments=5; //everything with less than this number of st #define MAX_CMD_SIZE 96 #define BUFSIZE 4 +// Bad Serial-connections can miss a received command by sending an 'ok' +// Therefore some clients go after 30 seconds in a timeout. Some other clients start sending commands while receiving a 'wait'. +// This wait is only send when the buffer is empty. The timeout-length is in milliseconds. 1000 is a good value. +#define NO_TIMEOUTS 1000 + +// Some clients will have this feature soon. This could make the NO_TIMEOUTS unnecessary. +#define ADVANCED_OK + // @section fwretract // Firmware based and LCD controlled retract diff --git a/Marlin/example_configurations/SCARA/Configuration_adv.h b/Marlin/example_configurations/SCARA/Configuration_adv.h index a706696aad..2b7cbda07f 100644 --- a/Marlin/example_configurations/SCARA/Configuration_adv.h +++ b/Marlin/example_configurations/SCARA/Configuration_adv.h @@ -376,6 +376,14 @@ const unsigned int dropsegments=5; //everything with less than this number of st #define MAX_CMD_SIZE 96 #define BUFSIZE 4 +// Bad Serial-connections can miss a received command by sending an 'ok' +// Therefore some clients go after 30 seconds in a timeout. Some other clients start sending commands while receiving a 'wait'. +// This wait is only send when the buffer is empty. The timeout-length is in milliseconds. 1000 is a good value. +#define NO_TIMEOUTS 1000 + +// Some clients will have this feature soon. This could make the NO_TIMEOUTS unnecessary. +#define ADVANCED_OK + // @section fwretract // Firmware based and LCD controlled retract diff --git a/Marlin/example_configurations/WITBOX/Configuration_adv.h b/Marlin/example_configurations/WITBOX/Configuration_adv.h index 25abd17c2c..44f532cb17 100644 --- a/Marlin/example_configurations/WITBOX/Configuration_adv.h +++ b/Marlin/example_configurations/WITBOX/Configuration_adv.h @@ -374,7 +374,15 @@ const unsigned int dropsegments=5; //everything with less than this number of st //The ASCII buffer for receiving from the serial: #define MAX_CMD_SIZE 96 -#define BUFSIZE 5 +#define BUFSIZE 4 + +// Bad Serial-connections can miss a received command by sending an 'ok' +// Therefore some clients go after 30 seconds in a timeout. Some other clients start sending commands while receiving a 'wait'. +// This wait is only send when the buffer is empty. The timeout-length is in milliseconds. 1000 is a good value. +#define NO_TIMEOUTS 1000 + +// Some clients will have this feature soon. This could make the NO_TIMEOUTS unnecessary. +#define ADVANCED_OK // @section fwretract diff --git a/Marlin/example_configurations/delta/biv2.5/Configuration_adv.h b/Marlin/example_configurations/delta/biv2.5/Configuration_adv.h index d035073b8d..71666033ae 100644 --- a/Marlin/example_configurations/delta/biv2.5/Configuration_adv.h +++ b/Marlin/example_configurations/delta/biv2.5/Configuration_adv.h @@ -377,6 +377,14 @@ const unsigned int dropsegments=5; //everything with less than this number of st #define MAX_CMD_SIZE 96 #define BUFSIZE 4 +// Bad Serial-connections can miss a received command by sending an 'ok' +// Therefore some clients go after 30 seconds in a timeout. Some other clients start sending commands while receiving a 'wait'. +// This wait is only send when the buffer is empty. The timeout-length is in milliseconds. 1000 is a good value. +#define NO_TIMEOUTS 1000 + +// Some clients will have this feature soon. This could make the NO_TIMEOUTS unnecessary. +#define ADVANCED_OK + // @section fwretract // Firmware based and LCD controlled retract diff --git a/Marlin/example_configurations/delta/generic/Configuration_adv.h b/Marlin/example_configurations/delta/generic/Configuration_adv.h index cdfa7c8f93..2c193d38d4 100644 --- a/Marlin/example_configurations/delta/generic/Configuration_adv.h +++ b/Marlin/example_configurations/delta/generic/Configuration_adv.h @@ -377,6 +377,14 @@ const unsigned int dropsegments=5; //everything with less than this number of st #define MAX_CMD_SIZE 96 #define BUFSIZE 4 +// Bad Serial-connections can miss a received command by sending an 'ok' +// Therefore some clients go after 30 seconds in a timeout. Some other clients start sending commands while receiving a 'wait'. +// This wait is only send when the buffer is empty. The timeout-length is in milliseconds. 1000 is a good value. +#define NO_TIMEOUTS 1000 + +// Some clients will have this feature soon. This could make the NO_TIMEOUTS unnecessary. +#define ADVANCED_OK + // @section fwretract // Firmware based and LCD controlled retract diff --git a/Marlin/example_configurations/delta/kossel_mini/Configuration_adv.h b/Marlin/example_configurations/delta/kossel_mini/Configuration_adv.h index 943022c819..cfa54ce759 100644 --- a/Marlin/example_configurations/delta/kossel_mini/Configuration_adv.h +++ b/Marlin/example_configurations/delta/kossel_mini/Configuration_adv.h @@ -376,6 +376,14 @@ const unsigned int dropsegments=5; //everything with less than this number of st #define MAX_CMD_SIZE 96 #define BUFSIZE 4 +// Bad Serial-connections can miss a received command by sending an 'ok' +// Therefore some clients go after 30 seconds in a timeout. Some other clients start sending commands while receiving a 'wait'. +// This wait is only send when the buffer is empty. The timeout-length is in milliseconds. 1000 is a good value. +#define NO_TIMEOUTS 1000 + +// Some clients will have this feature soon. This could make the NO_TIMEOUTS unnecessary. +#define ADVANCED_OK + // @section fwretract // Firmware based and LCD controlled retract diff --git a/Marlin/example_configurations/makibox/Configuration_adv.h b/Marlin/example_configurations/makibox/Configuration_adv.h index 8d451fd282..845a98b4d0 100644 --- a/Marlin/example_configurations/makibox/Configuration_adv.h +++ b/Marlin/example_configurations/makibox/Configuration_adv.h @@ -376,6 +376,14 @@ const unsigned int dropsegments=5; //everything with less than this number of st #define MAX_CMD_SIZE 96 #define BUFSIZE 4 +// Bad Serial-connections can miss a received command by sending an 'ok' +// Therefore some clients go after 30 seconds in a timeout. Some other clients start sending commands while receiving a 'wait'. +// This wait is only send when the buffer is empty. The timeout-length is in milliseconds. 1000 is a good value. +#define NO_TIMEOUTS 1000 + +// Some clients will have this feature soon. This could make the NO_TIMEOUTS unnecessary. +#define ADVANCED_OK + // @section fwretract // Firmware based and LCD controlled retract diff --git a/Marlin/example_configurations/tvrrug/Round2/Configuration_adv.h b/Marlin/example_configurations/tvrrug/Round2/Configuration_adv.h index 3187150ba9..2fb6b492ef 100644 --- a/Marlin/example_configurations/tvrrug/Round2/Configuration_adv.h +++ b/Marlin/example_configurations/tvrrug/Round2/Configuration_adv.h @@ -376,6 +376,14 @@ const unsigned int dropsegments=5; //everything with less than this number of st #define MAX_CMD_SIZE 96 #define BUFSIZE 4 +// Bad Serial-connections can miss a received command by sending an 'ok' +// Therefore some clients go after 30 seconds in a timeout. Some other clients start sending commands while receiving a 'wait'. +// This wait is only send when the buffer is empty. The timeout-length is in milliseconds. 1000 is a good value. +#define NO_TIMEOUTS 1000 + +// Some clients will have this feature soon. This could make the NO_TIMEOUTS unnecessary. +#define ADVANCED_OK + // @section fwretract // Firmware based and LCD controlled retract