Skip to content

Commit

Permalink
Merge branch 'pr/19674' into Ender3SKRmini1.2
Browse files Browse the repository at this point in the history
  • Loading branch information
tomc committed Jul 9, 2021
2 parents 1f7be6c + 8434ce2 commit 1f90733
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
1 change: 1 addition & 0 deletions Marlin/src/MarlinCore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -815,6 +815,7 @@ void idle(bool no_stepper_sleep/*=false*/) {
TERN_(AUTO_REPORT_TEMPERATURES, thermalManager.auto_reporter.tick());
TERN_(AUTO_REPORT_SD_STATUS, card.auto_reporter.tick());
TERN_(AUTO_REPORT_POSITION, position_auto_reporter.tick());
TERN_(BUFFER_MONITORING, queue.auto_report_buffer_statistics());
}
#endif

Expand Down
39 changes: 39 additions & 0 deletions Marlin/src/gcode/queue.h
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,45 @@ class GCodeQueue {
*/
static void flush_and_request_resend(const serial_index_t serial_ind);

#if ENABLED(BUFFER_MONITORING)
/**
* Track buffer underruns
*/
static uint32_t command_buffer_underruns;
static bool command_buffer_empty;
static millis_t max_command_buffer_empty_duration;
static millis_t command_buffer_empty_at;

static uint32_t planner_buffer_underruns;
static bool planner_buffer_empty;
static millis_t max_planner_buffer_empty_duration;
static millis_t planner_buffer_empty_at;

/**
* Report buffer statistics to the host to be able to detect buffer underruns
*
* Returns "M576 " followed by:
* P<uint> Planner space remaining
* B<uint> Command buffer space remaining
* PU<uint> Number of planner buffer underruns since last report
* PD<uint> Max time in ms the planner buffer was empty since last report
* BU<uint> Number of command buffer underruns since last report
* BD<uint> Max time in ms the command buffer was empty since last report
*/
static void report_buffer_statistics();

static uint8_t auto_buffer_report_interval;
static millis_t next_buffer_report_ms;
static void auto_report_buffer_statistics();
static inline void set_auto_report_interval(uint8_t v) {
NOMORE(v, 60);
auto_buffer_report_interval = v;
next_buffer_report_ms = millis() + 1000UL * v;
}
#endif

private:

/**
* (Re)Set the current line number for the last received command
*/
Expand Down

0 comments on commit 1f90733

Please sign in to comment.