From 69538ca421371130047fce7965770e2f4ac6ab0e Mon Sep 17 00:00:00 2001 From: smallwhiteawhite <1368582937@qq.com> Date: Fri, 27 Nov 2026 23:30:18 -0800 Subject: [PATCH] rs274ngc: reject axis and polar words with G28.2 The G_28_2 branch in Interp::check_g_codes() was empty, so when a modal motion mode such as G0 was active, a block like G28.2 P0 X1 was accepted and queued both HOME_CYCLE_JOINT and a modal move in the same block before position resync, contradicting docs/src/gcode/g-code.adoc. Reject axis words (X-W) and polar coordinates (@, ^) on G28.2 blocks in check_g_codes(), matching the adjacent G53.1/G53.2/G53.6 check, and add regression tests under tests/interp/bad/. Ref #4918 --- src/emc/rs274ngc/interp_check.cc | 4 ++++ tests/interp/bad/g28.2-axis-word.ngc | 4 ++++ tests/interp/bad/g28.2-polar.ngc | 4 ++++ 3 files changed, 12 insertions(+) create mode 100644 tests/interp/bad/g28.2-axis-word.ngc create mode 100644 tests/interp/bad/g28.2-polar.ngc diff --git a/src/emc/rs274ngc/interp_check.cc b/src/emc/rs274ngc/interp_check.cc index 963f02b84c8..8e683e5b240 100644 --- a/src/emc/rs274ngc/interp_check.cc +++ b/src/emc/rs274ngc/interp_check.cc @@ -108,6 +108,10 @@ int Interp::check_g_codes(block_pointer block, //!< pointer to a block to be c } else if (mode1 == G_6_2){ } else if (mode0 == G_28_1 || mode0 == G_30_1) { } else if (mode0 == G_28_2) { // G-code homing + CHKS((block->x_flag || block->y_flag || block->z_flag || block->a_flag || block->b_flag || + block->c_flag || block->u_flag || block->v_flag || block->w_flag || + block->radius_flag || block->theta_flag), + _("Cannot use axis words with G28.2")); } else if (mode0 == G_52) { } else if (mode0 == G_53) { CHKS(((block->motion_to_be != G_0) && (block->motion_to_be != G_1)), diff --git a/tests/interp/bad/g28.2-axis-word.ngc b/tests/interp/bad/g28.2-axis-word.ngc new file mode 100644 index 00000000000..39fb6b5872b --- /dev/null +++ b/tests/interp/bad/g28.2-axis-word.ngc @@ -0,0 +1,4 @@ +;Cannot use axis words with G28.2 +G21 G90 G0 X0 +G28.2 P0 X1 +M2 diff --git a/tests/interp/bad/g28.2-polar.ngc b/tests/interp/bad/g28.2-polar.ngc new file mode 100644 index 00000000000..c7924ddb390 --- /dev/null +++ b/tests/interp/bad/g28.2-polar.ngc @@ -0,0 +1,4 @@ +;Cannot use axis words with G28.2 +G21 G90 G0 X0 Y0 +G28.2 P0 @2 ^45 +M2