From ba526a604221d3954cd9e10c3635d25fbfa06cba Mon Sep 17 00:00:00 2001 From: cnc Date: Tue, 2 Jun 2026 23:34:56 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BB=A7=E7=BB=AD=E6=8C=89=20align-linuxcnc=20?= =?UTF-8?q?=E7=BA=A6=E6=9D=9F=EF=BC=9A=E8=A1=A5=E8=BD=B4=E8=BF=90=E5=8A=A8?= =?UTF-8?q?=20native=20=E8=A6=86=E7=9B=96=EF=BC=8C=E6=B5=8B=E8=AF=95?= =?UTF-8?q?=E9=80=9A=E8=BF=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 结论:补齐 LinuxCNC interp_internal.cc enhance_block() 轴/运动错误 fixture 的 native 校验,并同步 check_other_codes() native 覆盖文档;./test-native.sh 与 ./test-linuxcnc-source-link.sh 均通过。 --- docs/linuxcnc-porting.md | 5 ++-- test-linuxcnc-rs274-native.sh | 48 +++++++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+), 2 deletions(-) diff --git a/docs/linuxcnc-porting.md b/docs/linuxcnc-porting.md index 88ac6eb..fadc8f8 100644 --- a/docs/linuxcnc-porting.md +++ b/docs/linuxcnc-porting.md @@ -191,6 +191,7 @@ This matrix tracks LinuxCNC feature coverage for the web/WASM simulator. A featu | Area | Status | Regression | | --- | --- | --- | | Basic modal motion `G0/G1/G2/G3` | covered, including `G91` incremental linear motion, R-format arcs, `G18`/`G19` arc plane mapping, and `G90.1`/`G91.1` IJK modes | `tests/gcode/linuxcnc_basic_motion.ngc`, `tests/gcode/basic_mill.ngc`, `tests/gcode/incremental_and_r_arc.ngc`, `tests/gcode/linuxcnc_arc_planes.ngc`, `tests/gcode/linuxcnc_arc_distance_modes.ngc` | +| Block-level axis/motion validation | covered through LinuxCNC native/source `enhance_block()` checks for invalid `G80` axes, missing `G52/G92` or motion axes, bare axes without active motion, and modal-0 axis consumers on motion blocks | `tests/gcode/linuxcnc_g80_axis_error.ngc`, `tests/gcode/linuxcnc_g52_missing_axis_error.ngc`, `tests/gcode/linuxcnc_g92_missing_axis_error.ngc`, `tests/gcode/linuxcnc_motion_missing_axis_error.ngc`, `tests/gcode/linuxcnc_axis_without_motion_error.ngc`, `tests/gcode/linuxcnc_motion_with_g92_axis_error.ngc` | | Predefined position moves `G28/G28.1`, `G30/G30.1` | covered for stored position, waypoint, selected-axis return, and all-axis return | `tests/gcode/linuxcnc_predefined_positions.ngc` | | Machine-coordinate move `G53` | covered for explicit/modal `G0`, `G1`, arc rejection, and incremental-mode rejection through LinuxCNC native/source backends | `tests/gcode/linuxcnc_machine_coordinates.ngc`, `tests/gcode/linuxcnc_g53_arc_error.ngc`, `tests/gcode/linuxcnc_g53_incremental_error.ngc` | | Tool select/change `T... M6` | covered with minimal native tooldata | `tests/gcode/basic_mill.ngc` | @@ -198,9 +199,9 @@ This matrix tracks LinuxCNC feature coverage for the web/WASM simulator. A featu | RTCP controls `G43.4/G43.5/G49` | covered as simulator-owned control lines | `tests/gcode/linuxcnc_rtcp_controls.ngc` | | Kinematics switch `M428/M429/M430` | covered as simulator-owned control lines | `tests/gcode/linuxcnc_rtcp_controls.ngc` | | Spindle, coolant, program stops, and current tool number `M3/M4/M5`, `M7/M8/M9`, `M0/M1/M60/M30`, `M61 Q...` | covered through LinuxCNC native/source backends, including source-linked `convert_m()` rejection of out-of-range `M3/M4/M5 $` spindle selectors and negative `M61 Q` | `tests/gcode/linuxcnc_spindle_direction.ngc`, `tests/gcode/linuxcnc_coolant.ngc`, `tests/gcode/linuxcnc_program_stops.ngc`, `tests/gcode/linuxcnc_tool_number.ngc`, `tests/gcode/linuxcnc_m3_spindle_dollar_out_of_range_error.ngc`, `tests/gcode/linuxcnc_m4_spindle_dollar_out_of_range_error.ngc`, `tests/gcode/linuxcnc_m5_spindle_dollar_out_of_range_error.ngc`, `tests/gcode/linuxcnc_m61_negative_q_error.ngc` | -| Spindle speed mode `G96/G97` | covered with Canon `SET_SPINDLE_MODE` preserved as mode state events, including `G96 D...` max-RPM value and source-linked `check_other_codes()` rejection of missing `S` with `G96` | `tests/gcode/linuxcnc_spindle_modes.ngc`, `tests/gcode/linuxcnc_g96_missing_s_word_error.ngc` | +| Spindle speed mode `G96/G97` | covered with Canon `SET_SPINDLE_MODE` preserved as mode state events, including `G96 D...` max-RPM value and native/source `check_other_codes()` rejection of missing `S` with `G96` | `tests/gcode/linuxcnc_spindle_modes.ngc`, `tests/gcode/linuxcnc_g96_missing_s_word_error.ngc` | | Spindle orientation `M19 R... P... Q...` | covered with Canon `ORIENT_SPINDLE` and `WAIT_SPINDLE_ORIENT_COMPLETE` preserved as temporary mode state events, including source-linked `check_other_codes()` validation for `P/R` words and `convert_m()` rejection of out-of-range `$` selectors and nonpositive `Q` waits | `tests/gcode/linuxcnc_spindle_orient.ngc`, `tests/gcode/linuxcnc_m19_spindle_dollar_out_of_range_error.ngc`, `tests/gcode/linuxcnc_m19_p_not_integer_error.ngc`, `tests/gcode/linuxcnc_m19_p_out_of_range_error.ngc`, `tests/gcode/linuxcnc_m19_r_out_of_range_error.ngc`, `tests/gcode/linuxcnc_m19_zero_q_error.ngc` | -| Spindle-synchronized feed and threading `G33/G33.1/G76` | covered through smoke, LinuxCNC native, and source-linked paths with Canon `START_SPEED_FEED_SYNCH`/`STOP_SPEED_FEED_SYNCH` preserved, rigid-tap line numbers normalized, G76 multi-pass threading smoke-covered, source-linked `check_other_codes()` validation for required/disallowed `K/F/P/I/J` words, and source-linked `convert_straight()`/`convert_threading_cycle()` rejection of invalid spindle state, spindle selector, rotary-axis motion, and G76 `I/J/K` geometry | `tests/gcode/linuxcnc_threading_sync.ngc`, `tests/gcode/linuxcnc_threading_cycle.ngc`, `tests/gcode/linuxcnc_g33_missing_k_word_error.ngc`, `tests/gcode/linuxcnc_g33_f_word_error.ngc`, `tests/gcode/linuxcnc_g33_1_missing_k_word_error.ngc`, `tests/gcode/linuxcnc_g33_1_f_word_error.ngc`, `tests/gcode/linuxcnc_g76_missing_p_word_error.ngc`, `tests/gcode/linuxcnc_g76_missing_i_word_error.ngc`, `tests/gcode/linuxcnc_g76_missing_j_word_error.ngc`, `tests/gcode/linuxcnc_g76_missing_k_word_error.ngc`, `tests/gcode/linuxcnc_g33_stopped_spindle_error.ngc`, `tests/gcode/linuxcnc_g33_1_stopped_spindle_error.ngc`, `tests/gcode/linuxcnc_g33_spindle_dollar_out_of_range_error.ngc`, `tests/gcode/linuxcnc_g33_1_spindle_dollar_out_of_range_error.ngc`, `tests/gcode/linuxcnc_g76_spindle_dollar_out_of_range_error.ngc`, `tests/gcode/linuxcnc_g76_stopped_spindle_error.ngc`, `tests/gcode/linuxcnc_g76_rotary_axis_error.ngc`, `tests/gcode/linuxcnc_g76_i_zero_error.ngc`, `tests/gcode/linuxcnc_g76_j_zero_error.ngc`, `tests/gcode/linuxcnc_g76_k_less_equal_j_error.ngc`, smoke API regression | +| Spindle-synchronized feed and threading `G33/G33.1/G76` | covered through smoke, LinuxCNC native, and source-linked paths with Canon `START_SPEED_FEED_SYNCH`/`STOP_SPEED_FEED_SYNCH` preserved, rigid-tap line numbers normalized, G76 multi-pass threading smoke-covered, native/source `check_other_codes()` validation for required/disallowed `K/F/P/I/J` words, and source-linked `convert_straight()`/`convert_threading_cycle()` rejection of invalid spindle state, spindle selector, rotary-axis motion, and G76 `I/J/K` geometry | `tests/gcode/linuxcnc_threading_sync.ngc`, `tests/gcode/linuxcnc_threading_cycle.ngc`, `tests/gcode/linuxcnc_g33_missing_k_word_error.ngc`, `tests/gcode/linuxcnc_g33_f_word_error.ngc`, `tests/gcode/linuxcnc_g33_1_missing_k_word_error.ngc`, `tests/gcode/linuxcnc_g33_1_f_word_error.ngc`, `tests/gcode/linuxcnc_g76_missing_p_word_error.ngc`, `tests/gcode/linuxcnc_g76_missing_i_word_error.ngc`, `tests/gcode/linuxcnc_g76_missing_j_word_error.ngc`, `tests/gcode/linuxcnc_g76_missing_k_word_error.ngc`, `tests/gcode/linuxcnc_g33_stopped_spindle_error.ngc`, `tests/gcode/linuxcnc_g33_1_stopped_spindle_error.ngc`, `tests/gcode/linuxcnc_g33_spindle_dollar_out_of_range_error.ngc`, `tests/gcode/linuxcnc_g33_1_spindle_dollar_out_of_range_error.ngc`, `tests/gcode/linuxcnc_g76_spindle_dollar_out_of_range_error.ngc`, `tests/gcode/linuxcnc_g76_stopped_spindle_error.ngc`, `tests/gcode/linuxcnc_g76_rotary_axis_error.ngc`, `tests/gcode/linuxcnc_g76_i_zero_error.ngc`, `tests/gcode/linuxcnc_g76_j_zero_error.ngc`, `tests/gcode/linuxcnc_g76_k_less_equal_j_error.ngc`, smoke API regression | | Lathe diameter/radius mode `G7/G8` | covered through LinuxCNC native/source backends for same-block X scaling, `G76` I/J/K threading geometry interaction, and `#<_lathe_diameter_mode>`/`#<_lathe_radius_mode>` readonly named-parameter state | `tests/gcode/linuxcnc_lathe_diameter_mode.ngc`, `tests/gcode/linuxcnc_lathe_diameter_g76.ngc` | | Digital/analog I/O `M62`-`M68` | covered with Canon digital output, analog output, and input wait callbacks preserved as temporary state events, including source-linked `convert_m()` validation for required `P`/`E`, M66 input selection, M66 wait timeout, and analog wait restrictions | `tests/gcode/linuxcnc_io_controls.ngc`, `tests/gcode/linuxcnc_m62_missing_p_word_error.ngc`, `tests/gcode/linuxcnc_m63_missing_p_word_error.ngc`, `tests/gcode/linuxcnc_m64_missing_p_word_error.ngc`, `tests/gcode/linuxcnc_m65_missing_p_word_error.ngc`, `tests/gcode/linuxcnc_m66_missing_input_error.ngc`, `tests/gcode/linuxcnc_m66_both_inputs_error.ngc`, `tests/gcode/linuxcnc_m66_zero_timeout_error.ngc`, `tests/gcode/linuxcnc_m66_analog_wait_error.ngc`, `tests/gcode/linuxcnc_m67_missing_e_word_error.ngc`, `tests/gcode/linuxcnc_m68_missing_e_word_error.ngc` | | Override controls `M48`-`M53` | covered with Canon feed override, spindle speed override, adaptive feed, and feed hold callbacks preserved as temporary state events | `tests/gcode/linuxcnc_override_controls.ngc` | diff --git a/test-linuxcnc-rs274-native.sh b/test-linuxcnc-rs274-native.sh index c91e6bd..dda3086 100755 --- a/test-linuxcnc-rs274-native.sh +++ b/test-linuxcnc-rs274-native.sh @@ -143,6 +143,29 @@ if CNC_SIM_RS274_VAR="$var_file" "$build_dir/linuxcnc_rs274_dump" tests/gcode/li echo "expected linuxcnc_modal_invalidate.ngc to fail" >&2 exit 1 fi +# Source basis: LinuxCNC src/emc/rs274ngc/interp_internal.cc +# enhance_block() assigns motion_to_be and rejects invalid axis use with G80, +# missing axes for G52/G92 or motion codes, bare axis words without active +# motion, and modal-0 G codes that consume axis values on a motion block. +enhance_block_error_cases=( + "linuxcnc_g80_axis_error|Cannot use axis values with g80" + "linuxcnc_g52_missing_axis_error|All axes missing with g52 or g92" + "linuxcnc_g92_missing_axis_error|All axes missing with g52 or g92" + "linuxcnc_motion_missing_axis_error|All axes missing with motion code" + "linuxcnc_axis_without_motion_error|Cannot use axis values without a g code that uses them" + "linuxcnc_motion_with_g92_axis_error|Cannot use two g codes that both use axis values" +) +for case in "${enhance_block_error_cases[@]}"; do + fixture=${case%%|*} + expected=${case#*|} + if CNC_SIM_RS274_VAR="$var_file" \ + "$build_dir/linuxcnc_rs274_dump" "tests/gcode/$fixture.ngc" \ + >"$output_dir/cnc_sim_linuxcnc_$fixture.json" 2>"$output_dir/cnc_sim_linuxcnc_$fixture.err"; then + echo "expected $fixture.ngc to fail" >&2 + exit 1 + fi + grep -Fq "$expected" "$output_dir/cnc_sim_linuxcnc_$fixture.err" +done # Source basis: LinuxCNC src/emc/rs274ngc/interp_check.cc # check_g_codes() rejects invalid modal-0 combinations for G4, G10, and G53 # before convert_g() executes motion or coordinate updates. @@ -287,6 +310,31 @@ for case in "${unused_word_error_cases[@]}"; do fi grep -Fq "$expected" "$output_dir/cnc_sim_linuxcnc_$fixture.err" done +# Source basis: LinuxCNC src/emc/rs274ngc/interp_check.cc +# check_other_codes() enforces required and disallowed words for G96, +# G33/G33.1, and G76 before motion conversion. +threading_check_error_cases=( + "linuxcnc_g96_missing_s_word_error|S word missing with G96" + "linuxcnc_g33_missing_k_word_error|K word missing with g33/g33.1" + "linuxcnc_g33_f_word_error|F word used with a g33/g33.1" + "linuxcnc_g33_1_missing_k_word_error|K word missing with g33/g33.1" + "linuxcnc_g33_1_f_word_error|F word used with a g33/g33.1" + "linuxcnc_g76_missing_p_word_error|P word missing with G76" + "linuxcnc_g76_missing_i_word_error|I J or K words missing with G76" + "linuxcnc_g76_missing_j_word_error|I J or K words missing with G76" + "linuxcnc_g76_missing_k_word_error|I J or K words missing with G76" +) +for case in "${threading_check_error_cases[@]}"; do + fixture=${case%%|*} + expected=${case#*|} + if CNC_SIM_RS274_FILE_MODE=1 CNC_SIM_RS274_VAR="$var_file" \ + "$build_dir/linuxcnc_rs274_dump" "tests/gcode/$fixture.ngc" \ + >"$output_dir/cnc_sim_linuxcnc_$fixture.json" 2>"$output_dir/cnc_sim_linuxcnc_$fixture.err"; then + echo "expected $fixture.ngc to fail" >&2 + exit 1 + fi + grep -Fq "$expected" "$output_dir/cnc_sim_linuxcnc_$fixture.err" +done CNC_SIM_RS274_VAR="$var_file" "$build_dir/linuxcnc_rs274_dump" tests/gcode/linuxcnc_threading_sync.ngc >"$output_dir/cnc_sim_linuxcnc_threading_sync.json" CNC_SIM_RS274_VAR="$var_file" "$build_dir/linuxcnc_rs274_dump" tests/gcode/linuxcnc_threading_cycle.ngc >"$output_dir/cnc_sim_linuxcnc_threading_cycle.json" # Source basis: LinuxCNC src/emc/rs274ngc/interp_convert.cc