From 5682e34393c0c162780bb6218eba4c59bbe00549 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sat, 26 Nov 2022 21:34:48 -0600 Subject: [PATCH] misc. cleanup --- Marlin/Configuration_adv.h | 17 ++++++++--------- Marlin/src/gcode/queue.cpp | 33 ++++++++++++++++----------------- Marlin/src/gcode/queue.h | 8 ++++---- 3 files changed, 28 insertions(+), 30 deletions(-) diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index c82731f485dd0..b65132a18568d 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -2407,17 +2407,16 @@ /** * Line Number Error Handler - * - * Add function to delay resend requests for line number - * errors, for Hosts that send N# line number with GCode. - * Prevents resend cycles causing stuttering and failure - * on systems with latency between Host and Printer. - * eg. Octoprint through ESP8266(WIFI) pass-through + * + * Add function to delay resend requests for line number errors, for Hosts that + * send N# line number with G-code. Prevents resend cycles causing stuttering + * and failure on systems with Host <-> Printer latency. + * e.g., Octoprint through ESP8266 (WIFI) pass-through. */ -#define RESEND_HANDLER +//#define RESEND_HANDLER #if ENABLED(RESEND_HANDLER) - #define RESEND_HANDLER_DROP_GCODE 1 //Number of GCode lines to drop before resend request sent to Host. Octprint>>ESP3D; Min 5 - //#define RESEND_HANDLER_NOTICE //Send additional details to host terminal + #define RESEND_HANDLER_DROP_GCODE 1 // Number of G-code lines to drop before resend request sent to Host. Octprint>>ESP3D; Min 5 + //#define RESEND_HANDLER_NOTICE // Send additional details to host terminal #endif #if ENABLED(SDSUPPORT) diff --git a/Marlin/src/gcode/queue.cpp b/Marlin/src/gcode/queue.cpp index 4ed164a258398..608b6e9a1ce68 100644 --- a/Marlin/src/gcode/queue.cpp +++ b/Marlin/src/gcode/queue.cpp @@ -63,7 +63,7 @@ PGMSTR(G28_STR, "G28"); GCodeQueue::SerialState GCodeQueue::serial_state[NUM_SERIAL] = { 0 }; GCodeQueue::RingBuffer GCodeQueue::ring_buffer = { 0 }; #if ENABLED(RESEND_HANDLER) - GCodeQueue::ResendCtrl GCodeQueue::resend_ctrl = { 0 , 0 , RESEND_HANDLER_DROP_GCODE }; + GCodeQueue::ResendCtrl GCodeQueue::resend_ctrl = { 0, 0, RESEND_HANDLER_DROP_GCODE }; #endif #if NO_TIMEOUTS > 0 @@ -491,16 +491,16 @@ void GCodeQueue::get_serial_commands() { if (n2pos) npos = n2pos; } - const long gcode_N = strtol(npos + 1, nullptr, 10); //Host sent GCode Line# from RX_buffer + const long gcode_N = strtol(npos + 1, nullptr, 10); // Host sent G-code Line# from RX_buffer /** * Resend Handler - Received line # != expected line number - * + * * Standard behaviour - Clear RX_Buffer; resend request to host - * Extended behaviour - Allow ignore_resend_max # of errors to be ignored. - * Required when latency present between Marlin>>Host allowing GCode in-flight to cause comms issue + * Extended behaviour - Allow ignore_resend_max # of errors to be ignored. + * Required when latency present between Marlin>>Host allowing G-code in-flight to cause comms issue * on resend requests, such as stuttering and print failure. - * Ignore_resend_max should not exceed expected in-flight GCode + RX_Buffer. RX_Buffer is cleared in + * Ignore_resend_max should not exceed expected in-flight G-code + RX_Buffer. RX_Buffer is cleared in * gcode_line_error, not ln_num_error_notice as next serial in buffer may be the required line. */ if (gcode_N != serial.last_N + 1 && !M110) { @@ -508,23 +508,22 @@ void GCodeQueue::get_serial_commands() { #if ENABLED(RESEND_HANDLER) const serial_index_t serial_ind = p; - if ((resend_ctrl.ignore_resend_count < resend_ctrl.ignore_resend_max - 1)) { //Threshold eliminated resends - if(serial_state[serial_ind.index].last_N != resend_ctrl.last_error_N){ //Is first error instance + if ((resend_ctrl.ignore_resend_count < resend_ctrl.ignore_resend_max - 1)) { // Threshold eliminated resends + if (serial_state[serial_ind.index].last_N != resend_ctrl.last_error_N) { // Is first error instance ln_num_error_notice(p, gcode_N); - resend_ctrl.last_error_N = serial_state[serial_ind.index].last_N; //Set last ignored error line - resend_ctrl.ignore_resend_count = 0; //Reset count as first instance + resend_ctrl.last_error_N = serial_state[serial_ind.index].last_N; // Set last ignored error line + resend_ctrl.ignore_resend_count = 0; // Reset count as first instance } - else { + else ln_num_error_notice(p, gcode_N); - } - resend_ctrl.ignore_resend_count += 1; //Capture anything that doesn't fall in prev if_stmt. Nothing should miss + resend_ctrl.ignore_resend_count += 1; // Capture anything that doesn't fall in prev if_stmt. Nothing should miss } - else{ //Exceeded maximum deleted requests or is a new resend request - resend_ctrl.ignore_resend_count = 0; //Reset counter - gcode_line_error(F(STR_ERR_LINE_NO), p); //Send resend request + else { // Exceeded maximum deleted requests or is a new resend request + resend_ctrl.ignore_resend_count = 0; // Reset counter + gcode_line_error(F(STR_ERR_LINE_NO), p); // Send resend request } #else - gcode_line_error(F(STR_ERR_LINE_NO), p); //Send resend request + gcode_line_error(F(STR_ERR_LINE_NO), p); // Send resend request #endif break; } diff --git a/Marlin/src/gcode/queue.h b/Marlin/src/gcode/queue.h index 48d7c5ce9178a..5a48bfaeff145 100644 --- a/Marlin/src/gcode/queue.h +++ b/Marlin/src/gcode/queue.h @@ -102,15 +102,15 @@ class GCodeQueue { /** * Resend handler to deal with Host>>Printer latency - */ + */ #if ENABLED(RESEND_HANDLER) struct ResendCtrl { - long last_error_N; //Record the last requested resend line number + long last_error_N; // Record the last requested resend line number uint8_t ignore_resend_count; - const uint8_t ignore_resend_max; //Number of resends requests deleted //LH this can be constant + const uint8_t ignore_resend_max; // Number of resends requests deleted //LH this can be constant }; - static ResendCtrl resend_ctrl; //resend ctrl variables + static ResendCtrl resend_ctrl; // Resend ctrl variables static void ln_num_error_notice(const serial_index_t serial_ind, const long host_gcode_N); #endif