Skip to content

Commit a302ea7

Browse files
committed
Revert "Manually add missing changes from Add M576: Buffer monitoring MarlinFirmware#19674"
This reverts commit 8444d59.
1 parent 8444d59 commit a302ea7

File tree

6 files changed

+4
-153
lines changed

6 files changed

+4
-153
lines changed

Marlin/Configuration_adv.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2211,14 +2211,6 @@
22112211
// Some clients will have this feature soon. This could make the NO_TIMEOUTS unnecessary.
22122212
#define ADVANCED_OK
22132213

2214-
/**
2215-
* Buffer monitoring
2216-
*
2217-
* To help diagnose print quality issues stemming from command buffers being empty,
2218-
* we add M576 which enables reporting of buffer empty
2219-
*/
2220-
//#define BUFFER_MONITORING
2221-
22222214
// Printrun may have trouble receiving long strings all at once.
22232215
// This option inserts short delays between lines of serial output.
22242216
#define SERIAL_OVERRUN_PROTECTION

Marlin/src/gcode/gcode.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -851,10 +851,6 @@ void GcodeSuite::process_parsed_command(const bool no_ok/*=false*/) {
851851
case 575: M575(); break; // M575: Set serial baudrate
852852
#endif
853853

854-
#if ENABLED(BUFFER_MONITORING) // M576: Buffer monitoring
855-
case 576: M576(); break;
856-
#endif
857-
858854
#if ENABLED(ADVANCED_PAUSE_FEATURE)
859855
case 600: M600(); break; // M600: Pause for Filament Change
860856
case 603: M603(); break; // M603: Configure Filament Change

Marlin/src/gcode/gcode.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -972,8 +972,6 @@ class GcodeSuite {
972972
static void M575();
973973
#endif
974974

975-
TERN_(BUFFER_MONITORING, static void M576());
976-
977975
#if ENABLED(ADVANCED_PAUSE_FEATURE)
978976
static void M600();
979977
static void M603();

Marlin/src/gcode/queue.cpp

Lines changed: 2 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -68,22 +68,8 @@ GCodeQueue::RingBuffer GCodeQueue::ring_buffer = { 0 };
6868
#endif
6969

7070
/**
71-
* Track buffer underruns
71+
* Serial command injection
7272
*/
73-
#if ENABLED(BUFFER_MONITORING)
74-
uint32_t GCodeQueue::command_buffer_underruns = 0;
75-
bool GCodeQueue::command_buffer_empty = false;
76-
millis_t GCodeQueue::max_command_buffer_empty_duration = 0;
77-
millis_t GCodeQueue::command_buffer_empty_at = 0;
78-
79-
uint32_t GCodeQueue::planner_buffer_underruns = 0;
80-
bool GCodeQueue::planner_buffer_empty = false;
81-
millis_t GCodeQueue::max_planner_buffer_empty_duration = 0;
82-
millis_t GCodeQueue::planner_buffer_empty_at = 0;
83-
84-
uint8_t GCodeQueue::auto_buffer_report_interval;
85-
millis_t GCodeQueue::next_buffer_report_ms;
86-
#endif
8773

8874
/**
8975
* Next Injected PROGMEM Command pointer. (nullptr == empty)
@@ -635,27 +621,7 @@ void GCodeQueue::advance() {
635621
if (process_injected_command_P() || process_injected_command()) return;
636622

637623
// Return if the G-code buffer is empty
638-
if (ring_buffer.empty()) {
639-
#if ENABLED(BUFFER_MONITORING)
640-
if (!command_buffer_empty) {
641-
command_buffer_empty = true;
642-
command_buffer_underruns++;
643-
command_buffer_empty_at = millis();
644-
}
645-
#endif
646-
return;
647-
}
648-
649-
#if ENABLED(BUFFER_MONITORING)
650-
if (command_buffer_empty) {
651-
static millis_t command_buffer_empty_duration;
652-
command_buffer_empty_duration = millis() - command_buffer_empty_at;
653-
if (command_buffer_empty_duration > max_command_buffer_empty_duration) {
654-
max_command_buffer_empty_duration = command_buffer_empty_duration;
655-
}
656-
command_buffer_empty = false;
657-
}
658-
#endif
624+
if (ring_buffer.empty()) return;
659625

660626
#if ENABLED(SDSUPPORT)
661627

@@ -698,52 +664,3 @@ void GCodeQueue::advance() {
698664
// The queue may be reset by a command handler or by code invoked by idle() within a handler
699665
ring_buffer.advance_pos(ring_buffer.index_r, -1);
700666
}
701-
702-
#if ENABLED(BUFFER_MONITORING)
703-
void GCodeQueue::report_buffer_statistics() {
704-
SERIAL_ECHO("M576");
705-
SERIAL_ECHOLNPAIR(SP_P_STR, int(planner.moves_free()),
706-
SP_B_STR, int(BUFSIZE - length),
707-
" PU", queue.planner_buffer_underruns,
708-
" PD", queue.max_planner_buffer_empty_duration,
709-
" BU", queue.command_buffer_underruns,
710-
" BD", queue.max_command_buffer_empty_duration,
711-
);
712-
713-
command_buffer_underruns = 0;
714-
max_command_buffer_empty_duration = 0;
715-
716-
planner_buffer_underruns = 0;
717-
max_planner_buffer_empty_duration = 0;
718-
}
719-
720-
void GCodeQueue::auto_report_buffer_statistics() {
721-
// Bit of a hack to try to catch planner buffer underruns without having logic
722-
// running inside Stepper::block_phase_isr
723-
if (planner.movesplanned() == 0) {
724-
if (!planner_buffer_empty) { // if the planner buffer wasn't empty, but now it is
725-
planner_buffer_empty = true;
726-
planner_buffer_underruns++;
727-
planner_buffer_empty_at = millis();
728-
}
729-
} else if (planner_buffer_empty) { // if the planner buffer was empty, but now it ain't
730-
static millis_t planner_buffer_empty_duration;
731-
planner_buffer_empty_duration = millis() - planner_buffer_empty_at;
732-
733-
// if it's longer than the currently tracked max duration, replace it
734-
if (planner_buffer_empty_duration > max_planner_buffer_empty_duration) {
735-
max_planner_buffer_empty_duration = planner_buffer_empty_duration;
736-
}
737-
738-
planner_buffer_empty = false;
739-
}
740-
741-
if (queue.auto_buffer_report_interval && ELAPSED(millis(), queue.next_buffer_report_ms)) {
742-
queue.next_buffer_report_ms = millis() + 1000UL * queue.auto_buffer_report_interval;
743-
PORT_REDIRECT(SERIAL_BOTH);
744-
report_buffer_statistics();
745-
PORT_RESTORE();
746-
}
747-
}
748-
749-
#endif

Marlin/src/gcode/queue.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,8 @@ class GCodeQueue {
236236
*/
237237
static inline void set_current_line_number(long n) { serial_state[ring_buffer.command_port().index].last_N = n; }
238238

239+
private:
240+
239241
static void get_serial_commands();
240242

241243
#if ENABLED(SDSUPPORT)

Marlin/src/gcode/stats/M576.cpp

Lines changed: 0 additions & 54 deletions
This file was deleted.

0 commit comments

Comments
 (0)