Fix/wipetower klipper m400 stalls (#17246)

* WipeTower2: on Klipper, sync motion only before temperature commands

Follow-up to #15133. On Klipper, flush_planner_queue() emitted M400 at
every toolchange boundary, stalling the toolhead over the tower. Keep the
sync only before M104/M109/M591, and drop the sync line left behind when
GCode.cpp strips the interface-temperature M109.

End the deretraction placeholder with a newline: without the M400 that
used to follow it, the next tower move was glued to the placeholder line,
skipped post_process_wipe_tower_moves and kept tower-local Y.

Creator 5 Pro, 247 toolchanges: 1235 M400 -> 247 (~30 min saved).

* Update src/libslic3r/GCode.cpp

Good point, done. The strip now uses flush_planner_queue_command() and follows whatever the tower writes.

Co-authored-by: Kris Austin <kris.austin@gmail.com>

* tests: move the wipe tower slice and shared checks into one helper

* WipeTower2: keep the sync at the end of the unload on Klipper

[change_filament_gcode] and Tn are macros on Klipper; their non-motion
parts run when parsed, so without the sync a filament-change macro could
run while the unload and ramming moves are still queued.

Creator 5 Pro, 247 toolchanges: 494 M400 instead of 1235 (247 in this PR
before). The other boundary flushes, which stalled the toolhead over the
tower, stay removed.

* tests: check the unload sync before each change_filament_gcode

* WipeTower2: don't sync the cooldown after the interface wipe

The reset to the base temperature after the interface wipe isn't
timing-critical, but its M400 stopped the head over the tower before the
tower perimeter. Test print, Creator 5 Pro, 247 toolchanges: 3:22 with
the sync, 3:17 without it.

* tests: check only the interface cooldown for a missing sync

* WipeTower2: skip the cooldown sync on Klipper only

---------

Co-authored-by: Kris Austin <kris.austin@gmail.com>
Co-authored-by: GhZserG <ghzserg@zmod.link>
This commit is contained in:
authored and GitHub committed 2026-11-06 18:58:00 +08:00
1 parent 73e64d3bc5
commit cb80a0db84
4 files changed
+110 -18

No files matched your search

+6 -1
View File
@@ -1910,7 +1910,12 @@ static std::vector<Vec2d> get_path_of_change_filament(const Print& print)
}
}
}
if (!skip_line) {
if (skip_line) {
// Also drop the planner sync WipeTower2 put right before the stripped M109.
const std::string sync = flush_planner_queue_command(gcodegen.config().gcode_flavor.value);
if (boost::ends_with(out, sync))
out.resize(out.size() - sync.size());
} else {
out.append(line);
if (line_end < tcr_rotated_gcode.size())
out.push_back('\n');