🚸 'G27 P' parameter check (#28172)

Co-authored-by: Scott Lahteine <thinkyhead@users.noreply.github.com>
This commit is contained in:
Andrew
2025-11-16 14:19:59 -05:00
committed by GitHub
parent c7e6b7924a
commit 9d55440d38
2 changed files with 21 additions and 16 deletions

View File

@@ -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

View File

@@ -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)