From 0850954ca825b326315fc0c057c1f8aef8e147c6 Mon Sep 17 00:00:00 2001 From: cnc Date: Fri, 5 Jun 2026 23:32:43 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A1=A5=E9=BD=90=20probe=20=E8=BD=AC=E6=8D=A2?= =?UTF-8?q?=E9=94=99=E8=AF=AF=E8=A6=86=E7=9B=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 结论:基于 LinuxCNC interp_convert.cc convert_probe(),native/source-link 现在覆盖零进给、G95 feed-per-rev 和起点等于终点三类 G38 probe 失败分支。 --- test-linuxcnc-rs274-native.sh | 19 +++++++++++++++++++ test-linuxcnc-source-link.sh | 19 +++++++++++++++++++ .../linuxcnc_probe_feed_per_rev_error.ngc | 4 ++++ .../linuxcnc_probe_start_too_close_error.ngc | 4 ++++ .../gcode/linuxcnc_probe_zero_feed_error.ngc | 2 ++ 5 files changed, 48 insertions(+) create mode 100644 tests/gcode/linuxcnc_probe_feed_per_rev_error.ngc create mode 100644 tests/gcode/linuxcnc_probe_start_too_close_error.ngc create mode 100644 tests/gcode/linuxcnc_probe_zero_feed_error.ngc diff --git a/test-linuxcnc-rs274-native.sh b/test-linuxcnc-rs274-native.sh index f30fb57..9ea8dec 100755 --- a/test-linuxcnc-rs274-native.sh +++ b/test-linuxcnc-rs274-native.sh @@ -525,6 +525,25 @@ for case in "${threading_convert_error_cases[@]}"; do fi grep -Fq "$expected" "$output_dir/cnc_sim_linuxcnc_$fixture.err" done +# Source basis: LinuxCNC src/emc/rs274ngc/interp_convert.cc convert_probe() +# rejects zero feed, feed-per-revolution mode, and degenerate probe moves before +# issuing STRAIGHT_PROBE(). +probe_convert_error_cases=( + "linuxcnc_probe_zero_feed_error|Cannot probe with zero feed rate" + "linuxcnc_probe_feed_per_rev_error|Cannot probe with feed per rev mode" + "linuxcnc_probe_start_too_close_error|Start point too close to probe point" +) +for case in "${probe_convert_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 diff --git a/test-linuxcnc-source-link.sh b/test-linuxcnc-source-link.sh index c026dc5..43cb323 100755 --- a/test-linuxcnc-source-link.sh +++ b/test-linuxcnc-source-link.sh @@ -1182,6 +1182,25 @@ for case in "${threading_convert_error_cases[@]}"; do fi grep -Fq "$expected" "$output_dir/cnc_sim_linuxcnc_source_$fixture.err" done +# Source basis: LinuxCNC src/emc/rs274ngc/interp_convert.cc convert_probe() +# rejects zero feed, feed-per-revolution mode, and degenerate probe moves before +# issuing STRAIGHT_PROBE(). +probe_convert_error_cases=( + "linuxcnc_probe_zero_feed_error|Cannot probe with zero feed rate" + "linuxcnc_probe_feed_per_rev_error|Cannot probe with feed per rev mode" + "linuxcnc_probe_start_too_close_error|Start point too close to probe point" +) +for case in "${probe_convert_error_cases[@]}"; do + fixture=${case%%|*} + expected=${case#*|} + if CNC_SIM_RS274_FILE_MODE=1 CNC_SIM_RS274_VAR="$var_file" \ + "$build_dir/linuxcnc_rs274_source_dump" "tests/gcode/$fixture.ngc" \ + >"$output_dir/cnc_sim_linuxcnc_source_$fixture.json" 2>"$output_dir/cnc_sim_linuxcnc_source_$fixture.err"; then + echo "expected $fixture.ngc to fail" >&2 + exit 1 + fi + grep -Fq "$expected" "$output_dir/cnc_sim_linuxcnc_source_$fixture.err" +done # Source basis: LinuxCNC src/emc/rs274ngc/interp_read.cc # read_items() only consumes a leading N word before item dispatch; # read_one_item() then uses the default reader table from interp_array.cc diff --git a/tests/gcode/linuxcnc_probe_feed_per_rev_error.ngc b/tests/gcode/linuxcnc_probe_feed_per_rev_error.ngc new file mode 100644 index 0000000..f09d310 --- /dev/null +++ b/tests/gcode/linuxcnc_probe_feed_per_rev_error.ngc @@ -0,0 +1,4 @@ +G21 G90 G17 +G95 +F1 +G38.2 Z1 diff --git a/tests/gcode/linuxcnc_probe_start_too_close_error.ngc b/tests/gcode/linuxcnc_probe_start_too_close_error.ngc new file mode 100644 index 0000000..360f5fa --- /dev/null +++ b/tests/gcode/linuxcnc_probe_start_too_close_error.ngc @@ -0,0 +1,4 @@ +G21 G90 G17 +G0 Z0 +F100 +G38.2 Z0 diff --git a/tests/gcode/linuxcnc_probe_zero_feed_error.ngc b/tests/gcode/linuxcnc_probe_zero_feed_error.ngc new file mode 100644 index 0000000..22c9580 --- /dev/null +++ b/tests/gcode/linuxcnc_probe_zero_feed_error.ngc @@ -0,0 +1,2 @@ +G21 G90 G17 +G38.2 Z1