From 55c75ffe80dbc49766233d4e8971f64f337df253 Mon Sep 17 00:00:00 2001 From: cnc Date: Tue, 2 Jun 2026 23:47:02 +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=E5=9B=BA=E5=AE=9A=E5=BE=AA?= =?UTF-8?q?=E7=8E=AF=20native=20=E8=A6=86=E7=9B=96=EF=BC=8C=E6=B5=8B?= =?UTF-8?q?=E8=AF=95=E9=80=9A=E8=BF=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 结论:补齐 LinuxCNC interp_cycles.cc 固定循环错误 fixture 的 native 校验,覆盖重复次数、平面轴/R、Q/P、主轴状态和 G87 必需字;./test-native.sh 与 ./test-linuxcnc-source-link.sh 均通过,未扩展 smoke。 --- docs/linuxcnc-porting.md | 2 +- test-linuxcnc-rs274-native.sh | 47 +++++++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+), 1 deletion(-) diff --git a/docs/linuxcnc-porting.md b/docs/linuxcnc-porting.md index 89d1551..1f6bbe3 100644 --- a/docs/linuxcnc-porting.md +++ b/docs/linuxcnc-porting.md @@ -208,7 +208,7 @@ This matrix tracks LinuxCNC feature coverage for the web/WASM simulator. A featu | Modal state save/restore `M70`-`M73` | covered for main-program save/invalidate/restore plus O-word subroutine autorestore in smoke parser, with native/source regressions checking restored distance mode, units, and XY plane motion | `tests/gcode/linuxcnc_modal_state.ngc`, `tests/gcode/linuxcnc_modal_autorestore.ngc` | | LinuxCNC read-only named parameters | common modal/unit/feed/spindle reads are covered through LinuxCNC native/source backends, with additional ccomp/spindle-mode readonly reads source-linked | `tests/gcode/linuxcnc_readonly_named_parameters.ngc`, `tests/gcode/linuxcnc_readonly_named_parameters_extra.ngc`, `tests/gcode/linuxcnc_lathe_diameter_mode.ngc` | | Feed and motion control modes `G93/G94/G95`, `G61/G61.1/G64` | covered through LinuxCNC native/source backends | `tests/gcode/linuxcnc_feed_modes.ngc`, `tests/gcode/linuxcnc_motion_modes.ngc` | -| Canned cycle `G81/G80` | covered for drilling expand-to-canon path, including `G18/G19` plane-specific depth-axis mapping for representative drilling/boring cycles | `tests/gcode/linuxcnc_canned_cycle.ngc`, `tests/gcode/linuxcnc_canned_cycle_planes.ngc` | +| Canned cycle `G73`-`G89`/`G80` | covered for drilling expand-to-canon path, `G18/G19` plane-specific depth-axis mapping for representative drilling/boring cycles, and native/source LinuxCNC `interp_cycles.cc` validation of repeat counts, required R/depth words, invalid rotary axes, Q/P words, and spindle state | `tests/gcode/linuxcnc_canned_cycle.ngc`, `tests/gcode/linuxcnc_canned_cycles_extended.ngc`, `tests/gcode/linuxcnc_canned_cycle_planes.ngc`, `tests/gcode/linuxcnc_canned_cycle_l0_error.ngc`, `tests/gcode/linuxcnc_canned_cycle_missing_r_error.ngc`, `tests/gcode/linuxcnc_canned_cycle_missing_z_error.ngc`, `tests/gcode/linuxcnc_canned_cycle_g18_missing_y_error.ngc`, `tests/gcode/linuxcnc_canned_cycle_g19_missing_x_error.ngc`, `tests/gcode/linuxcnc_canned_cycle_r_less_z_error.ngc`, `tests/gcode/linuxcnc_canned_cycle_g18_r_less_y_error.ngc`, `tests/gcode/linuxcnc_canned_cycle_g19_r_less_x_error.ngc`, `tests/gcode/linuxcnc_canned_cycle_u_in_xy_error.ngc`, `tests/gcode/linuxcnc_canned_cycle_a_error.ngc`, `tests/gcode/linuxcnc_canned_cycle_b_error.ngc`, `tests/gcode/linuxcnc_canned_cycle_c_error.ngc`, `tests/gcode/linuxcnc_canned_cycle_g73_missing_q_error.ngc`, `tests/gcode/linuxcnc_canned_cycle_g83_missing_q_error.ngc`, `tests/gcode/linuxcnc_canned_cycle_g73_q0_error.ngc`, `tests/gcode/linuxcnc_canned_cycle_g83_q0_error.ngc`, `tests/gcode/linuxcnc_canned_cycle_g82_missing_p_error.ngc`, `tests/gcode/linuxcnc_canned_cycle_g86_missing_p_error.ngc`, `tests/gcode/linuxcnc_canned_cycle_g88_missing_p_error.ngc`, `tests/gcode/linuxcnc_canned_cycle_g89_missing_p_error.ngc`, `tests/gcode/linuxcnc_canned_cycle_g74_clockwise_error.ngc`, `tests/gcode/linuxcnc_canned_cycle_g84_counterclockwise_error.ngc`, `tests/gcode/linuxcnc_canned_cycle_g74_stopped_spindle_error.ngc`, `tests/gcode/linuxcnc_canned_cycle_g84_stopped_spindle_error.ngc`, `tests/gcode/linuxcnc_canned_cycle_g86_stopped_spindle_error.ngc`, `tests/gcode/linuxcnc_canned_cycle_g88_stopped_spindle_error.ngc`, `tests/gcode/linuxcnc_canned_cycle_g87_stopped_spindle_error.ngc`, `tests/gcode/linuxcnc_canned_cycle_g87_missing_k_error.ngc`, `tests/gcode/linuxcnc_canned_cycle_g87_missing_i_error.ngc`, `tests/gcode/linuxcnc_canned_cycle_g87_missing_j_error.ngc` | | Coordinate offset Canon events `G10 L2`, `G10 L20`, `G10 P0 active-system targeting`, `G54`-`G59.3` selection, `G52`, `G92/G92.1/G92.2/G92.3` | covered through LinuxCNC native/source backends, including all nine G5X indices | `tests/gcode/linuxcnc_coordinate_offsets.ngc`, `tests/gcode/linuxcnc_coordinate_l20.ngc`, `tests/gcode/linuxcnc_coordinate_p0.ngc`, `tests/gcode/linuxcnc_coordinate_select_all.ngc`, `tests/gcode/linuxcnc_g92_restore.ngc`, `tests/gcode/linuxcnc_g52_offset.ngc` | | Cutter compensation | covered for tool-table `G41/G42 D...` and explicit-radius `G41.1/G42.1/G40` through LinuxCNC native/source backends | `tests/gcode/linuxcnc_cutter_comp.ngc` | | Probe moves `G38.2/G38.3/G38.4/G38.5` | covered as distinct probe events with LinuxCNC `probe_type` preserved through smoke, native, and source-linked paths | `tests/gcode/linuxcnc_probe_no_error.ngc` | diff --git a/test-linuxcnc-rs274-native.sh b/test-linuxcnc-rs274-native.sh index 3f075c0..eb5ddd2 100755 --- a/test-linuxcnc-rs274-native.sh +++ b/test-linuxcnc-rs274-native.sh @@ -427,6 +427,53 @@ for case in "${tool_length_offset_error_cases[@]}"; do 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_canned_cycle.ngc >"$output_dir/cnc_sim_linuxcnc_canned_cycle.json" +# Source basis: LinuxCNC src/emc/rs274ngc/interp_cycles.cc +# convert_cycle() and the G73/G74/G82-G89 helpers validate canned-cycle +# repeat counts, plane-specific axis/R words, Q/P requirements, and spindle +# state before expanding cycles to Canon motion. +canned_cycle_error_cases=( + "linuxcnc_canned_cycle_l0_error|Cannot do zero repeats of cycle" + "linuxcnc_canned_cycle_missing_r_error|R clearance plane unspecified in cycle" + "linuxcnc_canned_cycle_missing_z_error|Z value unspecified in xy plane canned cycle" + "linuxcnc_canned_cycle_g18_missing_y_error|Y value unspecified in xz plane canned cycle" + "linuxcnc_canned_cycle_g19_missing_x_error|X value unspecified in yz plane canned cycle" + "linuxcnc_canned_cycle_r_less_z_error|R less than z in cycle in xy plane" + "linuxcnc_canned_cycle_g18_r_less_y_error|R less than y in cycle in xz plane" + "linuxcnc_canned_cycle_g19_r_less_x_error|R less than x in cycle in yz plane" + "linuxcnc_canned_cycle_u_in_xy_error|Cannot put a U in a canned cycle in the XY plane" + "linuxcnc_canned_cycle_a_error|Cannot put an a in canned cycle" + "linuxcnc_canned_cycle_b_error|Cannot put a b in canned cycle" + "linuxcnc_canned_cycle_c_error|Cannot put a c in canned cycle" + "linuxcnc_canned_cycle_g73_missing_q_error|Q word missing with g73" + "linuxcnc_canned_cycle_g83_missing_q_error|Q word missing with g83" + "linuxcnc_canned_cycle_g73_q0_error|Negative or zero q value used" + "linuxcnc_canned_cycle_g83_q0_error|Negative or zero q value used" + "linuxcnc_canned_cycle_g82_missing_p_error|Dwell time p word missing with g82" + "linuxcnc_canned_cycle_g86_missing_p_error|Dwell time p word missing with g86" + "linuxcnc_canned_cycle_g88_missing_p_error|Dwell time p word missing with g88" + "linuxcnc_canned_cycle_g89_missing_p_error|Dwell time p word missing with g89" + "linuxcnc_canned_cycle_g74_clockwise_error|Spindle turning clockwise in G74" + "linuxcnc_canned_cycle_g84_counterclockwise_error|Spindle turning counterclockwise in G84" + "linuxcnc_canned_cycle_g74_stopped_spindle_error|Spindle not turning in G74" + "linuxcnc_canned_cycle_g84_stopped_spindle_error|Spindle not turning in G84" + "linuxcnc_canned_cycle_g86_stopped_spindle_error|Spindle not turning in g86" + "linuxcnc_canned_cycle_g88_stopped_spindle_error|Spindle not turning in g88" + "linuxcnc_canned_cycle_g87_stopped_spindle_error|Spindle not turning in g87" + "linuxcnc_canned_cycle_g87_missing_k_error|K word missing with g87" + "linuxcnc_canned_cycle_g87_missing_i_error|I word missing with g87" + "linuxcnc_canned_cycle_g87_missing_j_error|J word missing with g87" +) +for case in "${canned_cycle_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 CNC_SIM_RS274_VAR="$var_file" "$build_dir/linuxcnc_rs274_dump" tests/gcode/linuxcnc_canned_cycles_extended.ngc >"$output_dir/cnc_sim_linuxcnc_canned_cycles_extended.json" CNC_SIM_RS274_VAR="$var_file" "$build_dir/linuxcnc_rs274_dump" tests/gcode/linuxcnc_canned_cycle_planes.ngc >"$output_dir/cnc_sim_linuxcnc_canned_cycle_planes.json" CNC_SIM_RS274_VAR="$var_file" "$build_dir/linuxcnc_rs274_dump" tests/gcode/linuxcnc_arc_planes.ngc >"$output_dir/cnc_sim_linuxcnc_arc_planes.json"