Expand on serial debugging (#13577)

This commit is contained in:
Scott Lahteine
2019-04-05 20:02:46 -05:00
committed by GitHub
parent bf7b28b456
commit cf12fc8366
20 changed files with 93 additions and 271 deletions

View File

@ -227,13 +227,11 @@ bool I2CPositionEncoder::passes_test(const bool report) {
if (report) {
if (H != I2CPE_MAG_SIG_GOOD) SERIAL_ECHOPGM("Warning. ");
SERIAL_ECHO(axis_codes[encoderAxis]);
SERIAL_ECHOPGM(" axis ");
serialprintPGM(H == I2CPE_MAG_SIG_BAD ? PSTR("magnetic strip ") : PSTR("encoder "));
serial_ternary(H == I2CPE_MAG_SIG_BAD, PSTR(" axis "), PSTR("magnetic strip "), PSTR("encoder "));
switch (H) {
case I2CPE_MAG_SIG_GOOD:
case I2CPE_MAG_SIG_MID:
SERIAL_ECHOLNPGM("passes test; field strength ");
serialprintPGM(H == I2CPE_MAG_SIG_GOOD ? PSTR("good.\n") : PSTR("fair.\n"));
serial_ternary(H == I2CPE_MAG_SIG_GOOD, PSTR("passes test; field strength "), PSTR("good"), PSTR("fair"), PSTR(".\n"));
break;
default:
SERIAL_ECHOLNPGM("not detected!");

View File

@ -275,9 +275,8 @@ class I2CPositionEncodersMgr {
static void enable_ec(const int8_t idx, const bool enabled, const AxisEnum axis) {
CHECK_IDX();
encoders[idx].set_ec_enabled(enabled);
SERIAL_ECHOPAIR("Error correction on ", axis_codes[axis], " axis is ");
serialprintPGM(encoders[idx].get_ec_enabled() ? PSTR("en") : PSTR("dis"));
SERIAL_ECHOLNPGM("abled.");
SERIAL_ECHOPAIR("Error correction on ", axis_codes[axis]);
serial_ternary(encoders[idx].get_ec_enabled(), PSTR(" axis is "), PSTR("en"), PSTR("dis"), PSTR("abled.\n"));
}
static void set_ec_threshold(const int8_t idx, const float newThreshold, const AxisEnum axis) {

View File

@ -42,10 +42,6 @@
#define DEBUG_OUT ENABLED(DEBUG_LEVELING_FEATURE)
#include "../../core/debug_out.h"
#if ENABLED(G26_MESH_VALIDATION)
bool g26_debug_flag; // = false
#endif
bool leveling_is_valid() {
return
#if ENABLED(MESH_BED_LEVELING)

View File

@ -28,12 +28,6 @@ typedef struct {
float distance; // When populated, the distance from the search location
} mesh_index_pair;
#if ENABLED(G26_MESH_VALIDATION)
extern bool g26_debug_flag;
#else
constexpr bool g26_debug_flag = false;
#endif
#if ENABLED(PROBE_MANUALLY)
extern bool g29_in_progress;
#else

View File

@ -58,54 +58,10 @@
void unified_bed_leveling::report_state() {
echo_name();
SERIAL_ECHOPGM(" System v" UBL_VERSION " ");
if (!planner.leveling_active) SERIAL_ECHOPGM("in");
SERIAL_ECHOLNPGM("active.");
serial_ternary(planner.leveling_active, PSTR(" System v" UBL_VERSION " "), PSTR(""), PSTR("in"), PSTR("active\n"));
serial_delay(50);
}
#if ENABLED(UBL_DEVEL_DEBUGGING)
static void debug_echo_axis(const AxisEnum axis) {
if (current_position[axis] == destination[axis])
SERIAL_ECHOPGM("-------------");
else
SERIAL_ECHO_F(destination[X_AXIS], 6);
}
void debug_current_and_destination(PGM_P title) {
// if the title message starts with a '!' it is so important, we are going to
// ignore the status of the g26_debug_flag
if (*title != '!' && !g26_debug_flag) return;
const float de = destination[E_AXIS] - current_position[E_AXIS];
if (de == 0.0) return; // Printing moves only
const float dx = destination[X_AXIS] - current_position[X_AXIS],
dy = destination[Y_AXIS] - current_position[Y_AXIS],
xy_dist = HYPOT(dx, dy);
if (xy_dist == 0.0) return;
const float fpmm = de / xy_dist;
SERIAL_ECHOPAIR_F(" fpmm=", fpmm, 6);
SERIAL_ECHOPAIR_F(" current=( ", current_position[X_AXIS], 6);
SERIAL_ECHOPAIR_F(", ", current_position[Y_AXIS], 6);
SERIAL_ECHOPAIR_F(", ", current_position[Z_AXIS], 6);
SERIAL_ECHOPAIR_F(", ", current_position[E_AXIS], 6);
SERIAL_ECHOPGM(" ) destination=( "); debug_echo_axis(X_AXIS);
SERIAL_ECHOPGM(", "); debug_echo_axis(Y_AXIS);
SERIAL_ECHOPGM(", "); debug_echo_axis(Z_AXIS);
SERIAL_ECHOPGM(", "); debug_echo_axis(E_AXIS);
SERIAL_ECHOPGM(" ) ");
serialprintPGM(title);
SERIAL_EOL();
}
#endif // UBL_DEVEL_DEBUGGING
int8_t unified_bed_leveling::storage_slot;
float unified_bed_leveling::z_values[GRID_MAX_POINTS_X][GRID_MAX_POINTS_Y];

View File

@ -39,14 +39,6 @@
#define USE_NOZZLE_AS_REFERENCE 0
#define USE_PROBE_AS_REFERENCE 1
// ubl_motion.cpp
#if ENABLED(UBL_DEVEL_DEBUGGING)
void debug_current_and_destination(PGM_P const title);
#else
FORCE_INLINE void debug_current_and_destination(PGM_P const title) { UNUSED(title); }
#endif
// ubl_G29.cpp
enum MeshPointType : char { INVALID, REAL, SET_IN_BITMAP };

View File

@ -24,8 +24,6 @@
#if ENABLED(AUTO_BED_LEVELING_UBL)
//#define UBL_DEVEL_DEBUGGING
#include "ubl.h"
#include "../../../Marlin.h"

View File

@ -64,17 +64,6 @@
cell_dest_xi = get_cell_index_x(end[X_AXIS]),
cell_dest_yi = get_cell_index_y(end[Y_AXIS]);
if (g26_debug_flag) {
SERIAL_ECHOLNPAIR(
" ubl.line_to_destination_cartesian(xe=", destination[X_AXIS],
", ye=", destination[Y_AXIS],
", ze=", destination[Z_AXIS],
", ee=", destination[E_AXIS],
")"
);
debug_current_and_destination(PSTR("Start of ubl.line_to_destination_cartesian()"));
}
// A move within the same cell needs no splitting
if (cell_start_xi == cell_dest_xi && cell_start_yi == cell_dest_yi) {
@ -93,9 +82,6 @@
planner.buffer_segment(end[X_AXIS], end[Y_AXIS], end[Z_AXIS] + z_raise, end[E_AXIS], feed_rate, extruder);
set_current_from_destination();
if (g26_debug_flag)
debug_current_and_destination(PSTR("out of bounds in ubl.line_to_destination_cartesian()"));
return;
}
@ -119,9 +105,6 @@
// Replace NAN corrections with 0.0 to prevent NAN propagation.
planner.buffer_segment(end[X_AXIS], end[Y_AXIS], end[Z_AXIS] + (isnan(z0) ? 0.0 : z0), end[E_AXIS], feed_rate, extruder);
if (g26_debug_flag)
debug_current_and_destination(PSTR("FINAL_MOVE in ubl.line_to_destination_cartesian()"));
set_current_from_destination();
return;
}
@ -215,9 +198,6 @@
} //else printf("FIRST MOVE PRUNED ");
}
if (g26_debug_flag)
debug_current_and_destination(PSTR("vertical move done in ubl.line_to_destination_cartesian()"));
// At the final destination? Usually not, but when on a Y Mesh Line it's completed.
if (current_position[X_AXIS] != end[X_AXIS] || current_position[Y_AXIS] != end[Y_AXIS])
goto FINAL_MOVE;
@ -267,9 +247,6 @@
} //else printf("FIRST MOVE PRUNED ");
}
if (g26_debug_flag)
debug_current_and_destination(PSTR("horizontal move done in ubl.line_to_destination_cartesian()"));
if (current_position[X_AXIS] != end[X_AXIS] || current_position[Y_AXIS] != end[Y_AXIS])
goto FINAL_MOVE;
@ -353,9 +330,6 @@
if (xi_cnt < 0 || yi_cnt < 0) break; // Too far! Exit the loop and go to FINAL_MOVE
}
if (g26_debug_flag)
debug_current_and_destination(PSTR("generic move done in ubl.line_to_destination_cartesian()"));
if (current_position[X_AXIS] != end[X_AXIS] || current_position[Y_AXIS] != end[Y_AXIS])
goto FINAL_MOVE;

View File

@ -50,6 +50,9 @@ job_recovery_info_t PrintJobRecovery::info;
#include "fwretract.h"
#endif
#define DEBUG_OUT ENABLED(DEBUG_POWER_LOSS_RECOVERY)
#include "../core/debug_out.h"
PrintJobRecovery recovery;
/**
@ -110,9 +113,7 @@ void PrintJobRecovery::load() {
(void)file.read(&info, sizeof(info));
close();
}
#if ENABLED(DEBUG_POWER_LOSS_RECOVERY)
debug(PSTR("Load"));
#endif
debug(PSTR("Load"));
}
/**
@ -216,20 +217,14 @@ void PrintJobRecovery::save(const bool force/*=false*/, const bool save_queue/*=
*/
void PrintJobRecovery::write() {
#if ENABLED(DEBUG_POWER_LOSS_RECOVERY)
debug(PSTR("Write"));
#endif
debug(PSTR("Write"));
open(false);
file.seekSet(0);
const int16_t ret = file.write(&info, sizeof(info));
close();
#if ENABLED(DEBUG_POWER_LOSS_RECOVERY)
if (ret == -1) SERIAL_ECHOLNPGM("Power-loss file write failed.");
#else
UNUSED(ret);
#endif
if (ret == -1) DEBUG_ECHOLNPGM("Power-loss file write failed.");
}
/**
@ -367,65 +362,65 @@ void PrintJobRecovery::resume() {
#if ENABLED(DEBUG_POWER_LOSS_RECOVERY)
void PrintJobRecovery::debug(PGM_P const prefix) {
serialprintPGM(prefix);
SERIAL_ECHOLNPAIR(" Job Recovery Info...\nvalid_head:", int(info.valid_head), " valid_foot:", int(info.valid_foot));
DEBUG_PRINT_P(prefix);
DEBUG_ECHOLNPAIR(" Job Recovery Info...\nvalid_head:", int(info.valid_head), " valid_foot:", int(info.valid_foot));
if (info.valid_head) {
if (info.valid_head == info.valid_foot) {
SERIAL_ECHOPGM("current_position: ");
DEBUG_ECHOPGM("current_position: ");
LOOP_XYZE(i) {
if (i) SERIAL_CHAR(',');
SERIAL_ECHO(info.current_position[i]);
if (i) DEBUG_CHAR(',');
DEBUG_ECHO(info.current_position[i]);
}
SERIAL_EOL();
SERIAL_ECHOLNPAIR("feedrate: ", info.feedrate);
DEBUG_EOL();
DEBUG_ECHOLNPAIR("feedrate: ", info.feedrate);
#if HOTENDS > 1
SERIAL_ECHOLNPAIR("active_hotend: ", int(info.active_hotend));
DEBUG_ECHOLNPAIR("active_hotend: ", int(info.active_hotend));
#endif
SERIAL_ECHOPGM("target_temperature: ");
DEBUG_ECHOPGM("target_temperature: ");
HOTEND_LOOP() {
SERIAL_ECHO(info.target_temperature[e]);
if (e < HOTENDS - 1) SERIAL_CHAR(',');
DEBUG_ECHO(info.target_temperature[e]);
if (e < HOTENDS - 1) DEBUG_CHAR(',');
}
SERIAL_EOL();
DEBUG_EOL();
#if HAS_HEATED_BED
SERIAL_ECHOLNPAIR("target_temperature_bed: ", info.target_temperature_bed);
DEBUG_ECHOLNPAIR("target_temperature_bed: ", info.target_temperature_bed);
#endif
#if FAN_COUNT
SERIAL_ECHOPGM("fan_speed: ");
DEBUG_ECHOPGM("fan_speed: ");
FANS_LOOP(i) {
SERIAL_ECHO(int(info.fan_speed[i]));
if (i < FAN_COUNT - 1) SERIAL_CHAR(',');
DEBUG_ECHO(int(info.fan_speed[i]));
if (i < FAN_COUNT - 1) DEBUG_CHAR(',');
}
SERIAL_EOL();
DEBUG_EOL();
#endif
#if HAS_LEVELING
SERIAL_ECHOLNPAIR("leveling: ", int(info.leveling), "\n fade: ", int(info.fade));
DEBUG_ECHOLNPAIR("leveling: ", int(info.leveling), "\n fade: ", int(info.fade));
#endif
#if ENABLED(FWRETRACT)
SERIAL_ECHOPGM("retract: ");
DEBUG_ECHOPGM("retract: ");
for (int8_t e = 0; e < EXTRUDERS; e++) {
SERIAL_ECHO(info.retract[e]);
if (e < EXTRUDERS - 1) SERIAL_CHAR(',');
DEBUG_ECHO(info.retract[e]);
if (e < EXTRUDERS - 1) DEBUG_CHAR(',');
}
SERIAL_EOL();
SERIAL_ECHOLNPAIR("retract_hop: ", info.retract_hop);
DEBUG_EOL();
DEBUG_ECHOLNPAIR("retract_hop: ", info.retract_hop);
#endif
SERIAL_ECHOLNPAIR("cmd_queue_index_r: ", int(info.cmd_queue_index_r));
SERIAL_ECHOLNPAIR("commands_in_queue: ", int(info.commands_in_queue));
for (uint8_t i = 0; i < info.commands_in_queue; i++) SERIAL_ECHOLNPAIR("> ", info.command_queue[i]);
SERIAL_ECHOLNPAIR("sd_filename: ", info.sd_filename);
SERIAL_ECHOLNPAIR("sdpos: ", info.sdpos);
SERIAL_ECHOLNPAIR("print_job_elapsed: ", info.print_job_elapsed);
DEBUG_ECHOLNPAIR("cmd_queue_index_r: ", int(info.cmd_queue_index_r));
DEBUG_ECHOLNPAIR("commands_in_queue: ", int(info.commands_in_queue));
for (uint8_t i = 0; i < info.commands_in_queue; i++) DEBUG_ECHOLNPAIR("> ", info.command_queue[i]);
DEBUG_ECHOLNPAIR("sd_filename: ", info.sd_filename);
DEBUG_ECHOLNPAIR("sdpos: ", info.sdpos);
DEBUG_ECHOLNPAIR("print_job_elapsed: ", info.print_job_elapsed);
}
else
SERIAL_ECHOLNPGM("INVALID DATA");
DEBUG_ECHOLNPGM("INVALID DATA");
}
SERIAL_ECHOLNPGM("---");
DEBUG_ECHOLNPGM("---");
}
#endif // DEBUG_POWER_LOSS_RECOVERY

View File

@ -125,9 +125,11 @@ class PrintJobRecovery {
static inline bool valid() { return info.valid_head && info.valid_head == info.valid_foot; }
#if ENABLED(DEBUG_POWER_LOSS_RECOVERY)
static void debug(PGM_P const prefix);
#endif
#if ENABLED(DEBUG_POWER_LOSS_RECOVERY)
static void debug(PGM_P const prefix);
#else
static inline void debug(PGM_P const prefix) {}
#endif
private:
static void write();

View File

@ -474,7 +474,7 @@
switch (i) {
case TMC_PWM_SCALE: SERIAL_PRINT(st.PWM_SCALE(), DEC); break;
case TMC_SGT: SERIAL_PRINT(st.sgt(), DEC); break;
case TMC_STEALTHCHOP: serialprintPGM(st.en_pwm_mode() ? PSTR("true") : PSTR("false")); break;
case TMC_STEALTHCHOP: serialprint_truefalse(st.en_pwm_mode()); break;
default: break;
}
}
@ -497,7 +497,7 @@
switch (i) {
case TMC_PWM_SCALE: SERIAL_PRINT(st.PWM_SCALE(), DEC); break;
case TMC_SGT: SERIAL_PRINT(st.sgt(), DEC); break;
case TMC_STEALTHCHOP: serialprintPGM(st.en_pwm_mode() ? PSTR("true") : PSTR("false")); break;
case TMC_STEALTHCHOP: serialprint_truefalse(st.en_pwm_mode()); break;
case TMC_GLOBAL_SCALER:
{
uint16_t value = st.GLOBAL_SCALER();
@ -514,7 +514,7 @@
static void tmc_status(TMC2208Stepper &st, const TMC_debug_enum i) {
switch (i) {
case TMC_PWM_SCALE: SERIAL_PRINT(st.pwm_scale_sum(), DEC); break;
case TMC_STEALTHCHOP: serialprintPGM(st.stealth() ? PSTR("true") : PSTR("false")); break;
case TMC_STEALTHCHOP: serialprint_truefalse(st.stealth()); break;
case TMC_S2VSA: if (st.s2vsa()) SERIAL_CHAR('X'); break;
case TMC_S2VSB: if (st.s2vsb()) SERIAL_CHAR('X'); break;
default: break;
@ -541,7 +541,7 @@
SERIAL_CHAR('\t');
switch (i) {
case TMC_CODES: st.printLabel(); break;
case TMC_ENABLED: serialprintPGM(st.isEnabled() ? PSTR("true") : PSTR("false")); break;
case TMC_ENABLED: serialprint_truefalse(st.isEnabled()); break;
case TMC_CURRENT: SERIAL_ECHO(st.getMilliamps()); break;
case TMC_RMS_CURRENT: SERIAL_ECHO(st.rms_current()); break;
case TMC_MAX_CURRENT: SERIAL_PRINT((float)st.rms_current() * 1.41, 0); break;
@ -578,9 +578,9 @@
SERIAL_CHAR('-');
}
break;
case TMC_OTPW: serialprintPGM(st.otpw() ? PSTR("true") : PSTR("false")); break;
case TMC_OTPW: serialprint_truefalse(st.otpw()); break;
#if ENABLED(MONITOR_DRIVER_STATUS)
case TMC_OTPW_TRIGGERED: serialprintPGM(st.getOTPW() ? PSTR("true") : PSTR("false")); break;
case TMC_OTPW_TRIGGERED: serialprint_truefalse(st.getOTPW()); break;
#endif
case TMC_TOFF: SERIAL_PRINT(st.toff(), DEC); break;
case TMC_TBL: SERIAL_PRINT(st.blank_time(), DEC); break;
@ -596,7 +596,7 @@
SERIAL_CHAR('\t');
switch (i) {
case TMC_CODES: st.printLabel(); break;
case TMC_ENABLED: serialprintPGM(st.isEnabled() ? PSTR("true") : PSTR("false")); break;
case TMC_ENABLED: serialprint_truefalse(st.isEnabled()); break;
case TMC_CURRENT: SERIAL_ECHO(st.getMilliamps()); break;
case TMC_RMS_CURRENT: SERIAL_ECHO(st.rms_current()); break;
case TMC_MAX_CURRENT: SERIAL_PRINT((float)st.rms_current() * 1.41, 0); break;
@ -606,8 +606,8 @@
break;
case TMC_VSENSE: serialprintPGM(st.vsense() ? PSTR("1=.165") : PSTR("0=.310")); break;
case TMC_MICROSTEPS: SERIAL_ECHO(st.microsteps()); break;
//case TMC_OTPW: serialprintPGM(st.otpw() ? PSTR("true") : PSTR("false")); break;
//case TMC_OTPW_TRIGGERED: serialprintPGM(st.getOTPW() ? PSTR("true") : PSTR("false")); break;
//case TMC_OTPW: serialprint_truefalse(st.otpw()); break;
//case TMC_OTPW_TRIGGERED: serialprint_truefalse(st.getOTPW()); break;
case TMC_SGT: SERIAL_PRINT(st.sgt(), DEC); break;
case TMC_TOFF: SERIAL_PRINT(st.toff(), DEC); break;
case TMC_TBL: SERIAL_PRINT(st.blank_time(), DEC); break;

View File

@ -227,7 +227,7 @@ void tmc_set_current(TMC &st, const int mA) {
void tmc_report_otpw(TMC &st) {
st.printLabel();
SERIAL_ECHOPGM(" temperature prewarn triggered: ");
serialprintPGM(st.getOTPW() ? PSTR("true") : PSTR("false"));
serialprint_truefalse(st.getOTPW());
SERIAL_EOL();
}
template<typename TMC>