From 9d55440d38718667ad28aae38959175f22909c41 Mon Sep 17 00:00:00 2001 From: Andrew <18502096+classicrocker883@users.noreply.github.com> Date: Sun, 16 Nov 2025 14:19:59 -0500 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=B8=20'G27=20P'=20parameter=20check=20?= =?UTF-8?q?(#28172)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Scott Lahteine --- Marlin/src/gcode/feature/pause/G27.cpp | 9 +++++++-- Marlin/src/gcode/parser.h | 28 +++++++++++++------------- 2 files changed, 21 insertions(+), 16 deletions(-) diff --git a/Marlin/src/gcode/feature/pause/G27.cpp b/Marlin/src/gcode/feature/pause/G27.cpp index 99159cf66e..1fe6a490ea 100644 --- a/Marlin/src/gcode/feature/pause/G27.cpp +++ b/Marlin/src/gcode/feature/pause/G27.cpp @@ -44,8 +44,13 @@ void GcodeSuite::G27() { // Don't allow nozzle parking without homing first if (homing_needed_error()) return; - nozzle.park(parser.ushortval('P')); - TERN_(SOVOL_SV06_RTS, RTS_MoveAxisHoming()); + const int16_t pval = parser.intval('P'); + if (WITHIN(pval, 0, 4)) { + nozzle.park(pval); + TERN_(SOVOL_SV06_RTS, RTS_MoveAxisHoming()); + } + else + SERIAL_ECHOLN(F("?Invalid "), F("[P]arking style (0..4).")); } #endif // NOZZLE_PARK_FEATURE diff --git a/Marlin/src/gcode/parser.h b/Marlin/src/gcode/parser.h index 8e27064b63..71cad6857d 100644 --- a/Marlin/src/gcode/parser.h +++ b/Marlin/src/gcode/parser.h @@ -281,7 +281,7 @@ public: // Reduce to fewer bits static int16_t value_int() { return (int16_t)value_long(); } - static uint16_t value_ushort() { return (uint16_t)value_long(); } + static uint16_t value_ushort() { return (uint16_t)value_ulong(); } static uint8_t value_byte() { return (uint8_t)constrain(value_long(), 0, 255); } // Bool is true with no value or non-zero @@ -324,7 +324,7 @@ public: return linear_unit_factor; } - static float linear_value_to_mm(const float v) { return v * linear_unit_factor; } + static float linear_value_to_mm(const float v) { return v * linear_unit_factor; } static float axis_value_to_mm(const AxisEnum axis, const float v) { return v * axis_unit_factor(axis); } static float per_axis_value(const AxisEnum axis, const float v) { return v / axis_unit_factor(axis); } @@ -420,19 +420,19 @@ public: void unknown_command_warning(); // Provide simple value accessors with default option - static char* stringval(const char c, char * const dval=nullptr) { return seenval(c) ? value_string() : dval; } - static float floatval(const char c, const float dval=0.0) { return seenval(c) ? value_float() : dval; } - static bool boolval(const char c, const bool dval=false) { return seenval(c) ? value_bool() : (seen(c) ? true : dval); } - static uint8_t byteval(const char c, const uint8_t dval=0) { return seenval(c) ? value_byte() : dval; } - static int16_t intval(const char c, const int16_t dval=0) { return seenval(c) ? value_int() : dval; } - static uint16_t ushortval(const char c, const uint16_t dval=0) { return seenval(c) ? value_ushort() : dval; } - static int32_t longval(const char c, const int32_t dval=0) { return seenval(c) ? value_long() : dval; } - static uint32_t ulongval(const char c, const uint32_t dval=0) { return seenval(c) ? value_ulong() : dval; } - static float linearval(const char c, const float dval=0) { return seenval(c) ? value_linear_units() : dval; } + static char* stringval(const char c, char * const dval=nullptr) { return seenval(c) ? value_string() : dval; } + static float floatval(const char c, const float dval=0.0) { return seenval(c) ? value_float() : dval; } + static bool boolval(const char c, const bool dval=false) { return seenval(c) ? value_bool() : (seen(c) ? true : dval); } + static uint8_t byteval(const char c, const uint8_t dval=0) { return seenval(c) ? value_byte() : dval; } + static int16_t intval(const char c, const int16_t dval=0) { return seenval(c) ? value_int() : dval; } + static uint16_t ushortval(const char c, const uint16_t dval=0) { return seenval(c) ? value_ushort() : dval; } + static int32_t longval(const char c, const int32_t dval=0) { return seenval(c) ? value_long() : dval; } + static uint32_t ulongval(const char c, const uint32_t dval=0) { return seenval(c) ? value_ulong() : dval; } + static float linearval(const char c, const float dval=0) { return seenval(c) ? value_linear_units() : dval; } static float axisunitsval(const char c, const AxisEnum a, const float dval=0) - { return seenval(c) ? value_axis_units(a) : dval; } - static celsius_t celsiusval(const char c, const celsius_t dval=0) { return seenval(c) ? value_celsius() : dval; } - static feedRate_t feedrateval(const char c, const feedRate_t dval=0) { return seenval(c) ? value_feedrate() : dval; } + { return seenval(c) ? value_axis_units(a) : dval; } + static celsius_t celsiusval(const char c, const celsius_t dval=0) { return seenval(c) ? value_celsius() : dval; } + static feedRate_t feedrateval(const char c, const feedRate_t dval=0) { return seenval(c) ? value_feedrate() : dval; } #if ENABLED(MARLIN_DEV_MODE)