* M111: Set the debug level */
| 27 | * M111: Set the debug level |
| 28 | */ |
| 29 | void GcodeSuite::M111() { |
| 30 | if (parser.seenval('S')) marlin_debug_flags = parser.value_byte(); |
| 31 | #if ENABLED(DEBUG_FLAGS_GCODE) |
| 32 | static PGMSTR(str_debug_1, STR_DEBUG_ECHO); |
| 33 | static PGMSTR(str_debug_2, STR_DEBUG_INFO); |
| 34 | static PGMSTR(str_debug_4, STR_DEBUG_ERRORS); |
| 35 | #endif |
| 36 | static PGMSTR(str_debug_8, STR_DEBUG_DRYRUN); |
| 37 | #if ENABLED(DEBUG_FLAGS_GCODE) |
| 38 | static PGMSTR(str_debug_16, STR_DEBUG_COMMUNICATION); |
| 39 | #endif |
| 40 | #if ENABLED(DEBUG_LEVELING_FEATURE) |
| 41 | static PGMSTR(str_debug_detail, STR_DEBUG_DETAIL); |
| 42 | #endif |
| 43 | |
| 44 | static PGM_P const debug_strings[] PROGMEM = { |
| 45 | TERN(DEBUG_FLAGS_GCODE, str_debug_1, nullptr), |
| 46 | TERN(DEBUG_FLAGS_GCODE, str_debug_2, nullptr), |
| 47 | TERN(DEBUG_FLAGS_GCODE, str_debug_4, nullptr), |
| 48 | str_debug_8, |
| 49 | TERN(DEBUG_FLAGS_GCODE, str_debug_16, nullptr), |
| 50 | TERN_(DEBUG_LEVELING_FEATURE, str_debug_detail) |
| 51 | }; |
| 52 | |
| 53 | SERIAL_ECHO_START(); |
| 54 | SERIAL_ECHOPGM(STR_DEBUG_PREFIX); |
| 55 | if (marlin_debug_flags) { |
| 56 | uint8_t comma = 0; |
| 57 | for (uint8_t i = 0; i < COUNT(debug_strings); ++i) { |
| 58 | PGM_P const pstr = (PGM_P)pgm_read_ptr(&debug_strings[i]); |
| 59 | if (pstr && TEST(marlin_debug_flags, i)) { |
| 60 | if (comma++) SERIAL_CHAR(','); |
| 61 | SERIAL_ECHOPGM_P(pstr); |
| 62 | } |
| 63 | } |
| 64 | } |
| 65 | else { |
| 66 | SERIAL_ECHOPGM(STR_DEBUG_OFF); |
| 67 | #if !(defined(__AVR__) && defined(USBCON)) |
| 68 | #if ENABLED(SERIAL_STATS_RX_BUFFER_OVERRUNS) |
| 69 | SERIAL_ECHOPGM("\nBuffer Overruns: ", MYSERIAL1.buffer_overruns()); |
| 70 | #endif |
| 71 | #if ENABLED(SERIAL_STATS_RX_FRAMING_ERRORS) |
| 72 | SERIAL_ECHOPGM("\nFraming Errors: ", MYSERIAL1.framing_errors()); |
| 73 | #endif |
| 74 | #if ENABLED(SERIAL_STATS_DROPPED_RX) |
| 75 | SERIAL_ECHOPGM("\nDropped bytes: ", MYSERIAL1.dropped()); |
| 76 | #endif |
| 77 | #if ENABLED(SERIAL_STATS_MAX_RX_QUEUED) |
| 78 | SERIAL_ECHOPGM("\nMax RX Queue Size: ", MYSERIAL1.rxMaxEnqueued()); |
| 79 | #endif |
| 80 | #endif // !(__AVR__ && USBCON) |
| 81 | } |
| 82 | SERIAL_EOL(); |
| 83 | } |
nothing calls this directly
no test coverage detected