From 486437ed5f6bf1644fc5802a1caa2a73a4b735ac Mon Sep 17 00:00:00 2001 From: Stephen Hurd Date: Mon, 21 Sep 2020 23:14:36 -0400 Subject: [PATCH] Fix G35 on Arduino The tramming_point_name[] array is PROGMEM and points to PGMSTR() strings... this apparently means it can't be used with SERIAL_ECHOPAIR() on Arduino. On my CR-10 v3 with original Creality board, the first output sent a long string of characters to the serial port and then hung. This change allows it to work correctly. NOTE: The debug output wasn't tested, and I'm sure there's a better way of doing this, but I'm not familiar enough with the firmware to know what SERIAL_*() macro is appropriate for this. --- Marlin/src/gcode/bedlevel/G35.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/Marlin/src/gcode/bedlevel/G35.cpp b/Marlin/src/gcode/bedlevel/G35.cpp index 7595067dbf85..111fd26fc8c9 100755 --- a/Marlin/src/gcode/bedlevel/G35.cpp +++ b/Marlin/src/gcode/bedlevel/G35.cpp @@ -126,14 +126,18 @@ void GcodeSuite::G35() { const float z_probed_height = probe.probe_at_point(screws_tilt_adjust_pos[i], PROBE_PT_RAISE, 0, true); if (isnan(z_probed_height)) { - SERIAL_ECHOPAIR("G35 failed at point ", int(i), " (", tramming_point_name[i], ")"); + SERIAL_ECHOPAIR("G35 failed at point ", int(i), " ("); + serialprintPGM((char *)pgm_read_ptr(&tramming_point_name[i])); + serialprintPGM(PSTR(")")); SERIAL_ECHOLNPAIR_P(SP_X_STR, screws_tilt_adjust_pos[i].x, SP_Y_STR, screws_tilt_adjust_pos[i].y); err_break = true; break; } if (DEBUGGING(LEVELING)) { - DEBUG_ECHOPAIR("Probing point ", int(i), " (", tramming_point_name[i], ")"); + DEBUG_ECHOPAIR("Probing point ", int(i), " ("); + DEBUG_PRINT_P((char *)pgm_read_ptr(&tramming_point_name[i])); + DEBUG_PRINT_P(PSTR(")")); SERIAL_ECHOLNPAIR_P(SP_X_STR, screws_tilt_adjust_pos[i].x, SP_Y_STR, screws_tilt_adjust_pos[i].y, SP_Z_STR, z_probed_height); } @@ -152,8 +156,9 @@ void GcodeSuite::G35() { const float decimal_part = adjust - float(full_turns); const int minutes = trunc(decimal_part * 60.0f); - SERIAL_ECHOPAIR("Turn ", tramming_point_name[i], - " ", (screw_thread & 1) == (adjust > 0) ? "Counter-Clockwise" : "Clockwise", + serialprintPGM(PSTR("Turn ")); + serialprintPGM((char *)pgm_read_ptr(&tramming_point_name[i])); + SERIAL_ECHOPAIR(" ", (screw_thread & 1) == (adjust > 0) ? "Counter-Clockwise" : "Clockwise", " by ", abs(full_turns), " turns"); if (minutes) SERIAL_ECHOPAIR(" and ", abs(minutes), " minutes"); SERIAL_EOL();