Flush the wipe tower planner queue with M400 on Klipper

The wipe tower emitted G4 S0 to make the firmware finish its queued moves
before commands that must not take effect early. Klipper's G4 reads only the
P parameter, so that flush never happened there and a temperature change could
land seconds ahead of the moves it was meant to follow. Klipper now gets M400
instead, through one helper shared by both wipe tower implementations.

No change to any other firmware flavor's output, so no shipped profile or saved
project is affected.
This commit is contained in:
SoftFever
2026-08-05 01:21:32 +08:00
parent 6312caaf13
commit 4e1caa39eb
5 changed files with 47 additions and 5 deletions

View File

@@ -0,0 +1,27 @@
#include <catch2/catch_all.hpp>
#include <string>
#include "libslic3r/GCode/WipeTower.hpp"
#include "libslic3r/PrintConfig.hpp"
using namespace Slic3r;
// The wipe tower flushes the firmware's motion queue before a command or custom-G-code
// boundary that must not be reached early (an extruder-position reset, entering custom
// G-code). Klipper acts on those the moment it parses them, and its G4 reads only P, so the
// zero dwell every other flavor uses is not a flush there.
TEST_CASE("Klipper flushes the wipe tower planner queue with M400", "[WipeTower]")
{
CHECK(std::string(flush_planner_queue_command(gcfKlipper)) == "M400\n");
}
TEST_CASE("Other flavors flush the wipe tower planner queue with a zero dwell", "[WipeTower]")
{
const GCodeFlavor flavor = GENERATE(gcfMarlinLegacy, gcfRepRapFirmware, gcfRepetier,
gcfMarlinFirmware, gcfRepRapSprinter, gcfTeacup,
gcfMakerWare, gcfSailfish, gcfMach3, gcfMachinekit,
gcfSmoothie, gcfNoExtrusion);
INFO("gcode flavor enum value: " << int(flavor));
CHECK(std::string(flush_planner_queue_command(flavor)) == "G4 S0\n");
}