From 2f7a46758ba192318fc025057d73ee4b749387ac Mon Sep 17 00:00:00 2001 From: cnc Date: Wed, 3 Jun 2026 08:41:44 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8F=82=E8=80=83=E6=89=80=E6=9C=89=E5=88=86?= =?UTF-8?q?=E7=BB=84=EF=BC=9A=E8=A1=A5=20extended=20N=20=E8=A1=8C=E5=8F=B7?= =?UTF-8?q?=20source=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 --- test-all-native.sh | 1 + test-linuxcnc-source-link.sh | 19 ++++++++++++++++++- tests/gcode/linuxcnc_extended_linenumbers.ngc | 4 ++++ 3 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 tests/gcode/linuxcnc_extended_linenumbers.ngc diff --git a/test-all-native.sh b/test-all-native.sh index 10e69af..8b6ee28 100755 --- a/test-all-native.sh +++ b/test-all-native.sh @@ -562,6 +562,7 @@ grep -F 'tests/gcode/linuxcnc_lathe_diameter_g76.ngc' test-native.sh >/dev/null grep -F 'tests/gcode/linuxcnc_readonly_named_parameters.ngc' test-native.sh >/dev/null grep -F 'read_n_number()' test-linuxcnc-source-link.sh >/dev/null grep -F 'tests/gcode/linuxcnc_fractional_linenumbers.ngc' test-linuxcnc-source-link.sh >/dev/null +grep -F 'tests/gcode/linuxcnc_extended_linenumbers.ngc' test-linuxcnc-source-link.sh >/dev/null for script in \ test-native.sh \ diff --git a/test-linuxcnc-source-link.sh b/test-linuxcnc-source-link.sh index 84b3b07..1fa62ba 100755 --- a/test-linuxcnc-source-link.sh +++ b/test-linuxcnc-source-link.sh @@ -1485,12 +1485,16 @@ CNC_SIM_RS274_VAR="$var_file" \ "$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_g62_xz_nurbs.ngc \ >"$output_dir/cnc_sim_linuxcnc_source_g62_xz_nurbs.json" # Source basis: LinuxCNC src/emc/rs274ngc/interp_read.cc read_n_number() -# accepts and ignores the fractional suffix after an N word; execute_block() +# accepts and ignores the fractional suffix after an N word, preserves leading +# zero line numbers, and has the >99999 range check disabled; execute_block() # in src/emc/rs274ngc/interp_execute.cc still tags canon output with the # interpreter sequence number. CNC_SIM_RS274_VAR="$var_file" \ "$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_fractional_linenumbers.ngc \ >"$output_dir/cnc_sim_linuxcnc_source_fractional_linenumbers.json" +CNC_SIM_RS274_VAR="$var_file" \ + "$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_extended_linenumbers.ngc \ + >"$output_dir/cnc_sim_linuxcnc_source_extended_linenumbers.json" CNC_SIM_RS274_SOURCE_OUTPUT_DIR="$output_dir" python3 - <<'PY' import json @@ -1540,6 +1544,18 @@ if fractional_spindle_states[:3] != [(1, 300), (2, 600), (3, 1200)]: f"{fractional_spindle_states!r}" ) +extended_linenumbers = load("cnc_sim_linuxcnc_source_extended_linenumbers.json") +extended_spindle_states = [ + (event["line"], event["spindle"]) + for event in extended_linenumbers + if event["type"] == "set-spindle" +] +if extended_spindle_states[:3] != [(1, 111), (2, 222), (3, 333)]: + raise SystemExit( + "unexpected source-linked extended N-word spindle sequence: " + f"{extended_spindle_states!r}" + ) + block_delete_off = load("cnc_sim_linuxcnc_source_block_delete_off.json") if not any( event["type"] == "linear-feed" and event["line"] == 2 and event["end"]["x"] == 5 @@ -3427,3 +3443,4 @@ echo "dumped $output_dir/cnc_sim_linuxcnc_source_g52_offset.json" echo "dumped $output_dir/cnc_sim_linuxcnc_source_g52_xz_nurbs.json" echo "dumped $output_dir/cnc_sim_linuxcnc_source_g62_xz_nurbs.json" echo "dumped $output_dir/cnc_sim_linuxcnc_source_fractional_linenumbers.json" +echo "dumped $output_dir/cnc_sim_linuxcnc_source_extended_linenumbers.json" diff --git a/tests/gcode/linuxcnc_extended_linenumbers.ngc b/tests/gcode/linuxcnc_extended_linenumbers.ngc new file mode 100644 index 0000000..bb7b76c --- /dev/null +++ b/tests/gcode/linuxcnc_extended_linenumbers.ngc @@ -0,0 +1,4 @@ +N000001 S111 +N100000 S222 +N123456789 S333 +M2