From 611e6417b4ca2f01b0cd9e1fb0bcb1184d646c7e Mon Sep 17 00:00:00 2001 From: cnc Date: Wed, 3 Jun 2026 09:22:26 +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=20NURBS=20source=20=E8=A6=86?= =?UTF-8?q?=E7=9B=96=EF=BC=8C=E6=B5=8B=E8=AF=95=E9=80=9A=E8=BF=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test-linuxcnc-rs274-native.sh | 29 +++++++++++++++++++ test-linuxcnc-source-link.sh | 29 +++++++++++++++++++ ...xcnc_g52_missing_y_control_point_error.ngc | 3 ++ .../linuxcnc_g52_nonpositive_p_error.ngc | 4 +++ ...cnc_g52_p_without_xy_after_start_error.ngc | 4 +++ tests/gcode/linuxcnc_g52_zero_feed_error.ngc | 2 ++ ...inuxcnc_g53_short_control_points_error.ngc | 4 +++ .../gcode/linuxcnc_g53_without_g52_error.ngc | 3 ++ .../linuxcnc_g62_k_non_integer_error.ngc | 3 ++ .../linuxcnc_g62_missing_p_order_error.ngc | 3 ++ .../linuxcnc_g62_missing_q_mode_error.ngc | 3 ++ .../linuxcnc_g62_p_non_integer_error.ngc | 3 ++ .../linuxcnc_g62_q_non_integer_error.ngc | 3 ++ .../linuxcnc_g62_q_out_of_range_error.ngc | 3 ++ tests/gcode/linuxcnc_g62_zero_feed_error.ngc | 2 ++ 15 files changed, 98 insertions(+) create mode 100644 tests/gcode/linuxcnc_g52_missing_y_control_point_error.ngc create mode 100644 tests/gcode/linuxcnc_g52_nonpositive_p_error.ngc create mode 100644 tests/gcode/linuxcnc_g52_p_without_xy_after_start_error.ngc create mode 100644 tests/gcode/linuxcnc_g52_zero_feed_error.ngc create mode 100644 tests/gcode/linuxcnc_g53_short_control_points_error.ngc create mode 100644 tests/gcode/linuxcnc_g53_without_g52_error.ngc create mode 100644 tests/gcode/linuxcnc_g62_k_non_integer_error.ngc create mode 100644 tests/gcode/linuxcnc_g62_missing_p_order_error.ngc create mode 100644 tests/gcode/linuxcnc_g62_missing_q_mode_error.ngc create mode 100644 tests/gcode/linuxcnc_g62_p_non_integer_error.ngc create mode 100644 tests/gcode/linuxcnc_g62_q_non_integer_error.ngc create mode 100644 tests/gcode/linuxcnc_g62_q_out_of_range_error.ngc create mode 100644 tests/gcode/linuxcnc_g62_zero_feed_error.ngc diff --git a/test-linuxcnc-rs274-native.sh b/test-linuxcnc-rs274-native.sh index 8446b95..b37be15 100755 --- a/test-linuxcnc-rs274-native.sh +++ b/test-linuxcnc-rs274-native.sh @@ -964,6 +964,35 @@ for case in "${binary_operation_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_nurbs() validates G5.2/G5.3/G6.2 control point, weight, order, +# knot, mode, and feed requirements before issuing NURBS canon output. +nurbs_error_cases=( + "linuxcnc_g52_missing_y_control_point_error|You must specify both X and Y coordinates for Control Points" + "linuxcnc_g52_p_without_xy_after_start_error|Can specify P without X and Y only for the first control point" + "linuxcnc_g52_nonpositive_p_error|Must specify positive weight P for every Control Point" + "linuxcnc_g52_zero_feed_error|Cannot make a NURBS with 0 feedrate" + "linuxcnc_g53_without_g52_error|Cannot use G5.3 without G5.2 first" + "linuxcnc_g53_short_control_points_error|You must specify a number of control points at least equal to the order L = 3" + "linuxcnc_g62_missing_p_order_error|Program the nurbs order P in the first block of instruction" + "linuxcnc_g62_p_non_integer_error|nurbs order P number is not an integer" + "linuxcnc_g62_missing_q_mode_error|Program the nurbs Q value (1,2,3) in the first block of nurbs instruction" + "linuxcnc_g62_q_out_of_range_error|nurbs Q value not in range 1 to 3" + "linuxcnc_g62_q_non_integer_error|nurbs Q number is not an integer" + "linuxcnc_g62_k_non_integer_error|nurbs K number is not an integer" + "linuxcnc_g62_zero_feed_error|Cannot make a nurbs with 0 feedrate" +) +for case in "${nurbs_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 cp "$base_var_file" "$var_file" CNC_SIM_RS274_VAR="$var_file" "$build_dir/linuxcnc_rs274_dump" tests/gcode/linuxcnc_coordinate_offsets.ngc >"$output_dir/cnc_sim_linuxcnc_coordinate_offsets.json" cp "$base_var_file" "$var_file" diff --git a/test-linuxcnc-source-link.sh b/test-linuxcnc-source-link.sh index 4543e68..46eea60 100755 --- a/test-linuxcnc-source-link.sh +++ b/test-linuxcnc-source-link.sh @@ -1456,6 +1456,35 @@ if ! grep -q "one plane must be selected for nurbs: XY, YZ, ZX" "$output_dir/cnc cat "$output_dir/cnc_sim_linuxcnc_source_g62_extended_plane_error.err" >&2 exit 1 fi +# Source basis: LinuxCNC src/emc/rs274ngc/interp_convert.cc +# convert_nurbs() validates G5.2/G5.3/G6.2 control point, weight, order, +# knot, mode, and feed requirements before issuing NURBS canon output. +nurbs_error_cases=( + "linuxcnc_g52_missing_y_control_point_error|You must specify both X and Y coordinates for Control Points" + "linuxcnc_g52_p_without_xy_after_start_error|Can specify P without X and Y only for the first control point" + "linuxcnc_g52_nonpositive_p_error|Must specify positive weight P for every Control Point" + "linuxcnc_g52_zero_feed_error|Cannot make a NURBS with 0 feedrate" + "linuxcnc_g53_without_g52_error|Cannot use G5.3 without G5.2 first" + "linuxcnc_g53_short_control_points_error|You must specify a number of control points at least equal to the order L = 3" + "linuxcnc_g62_missing_p_order_error|Program the nurbs order P in the first block of instruction" + "linuxcnc_g62_p_non_integer_error|nurbs order P number is not an integer" + "linuxcnc_g62_missing_q_mode_error|Program the nurbs Q value (1,2,3) in the first block of nurbs instruction" + "linuxcnc_g62_q_out_of_range_error|nurbs Q value not in range 1 to 3" + "linuxcnc_g62_q_non_integer_error|nurbs Q number is not an integer" + "linuxcnc_g62_k_non_integer_error|nurbs K number is not an integer" + "linuxcnc_g62_zero_feed_error|Cannot make a nurbs with 0 feedrate" +) +for case in "${nurbs_error_cases[@]}"; do + fixture=${case%%|*} + expected=${case#*|} + if 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 CNC_SIM_RS274_FILE_MODE=1 CNC_SIM_RS274_VAR="$var_file" \ "$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_g76only.ngc \ >"$output_dir/cnc_sim_linuxcnc_source_g76only.json" diff --git a/tests/gcode/linuxcnc_g52_missing_y_control_point_error.ngc b/tests/gcode/linuxcnc_g52_missing_y_control_point_error.ngc new file mode 100644 index 0000000..42da0be --- /dev/null +++ b/tests/gcode/linuxcnc_g52_missing_y_control_point_error.ngc @@ -0,0 +1,3 @@ +G21 G90 G17 +F100 +G5.2 X1 P1 diff --git a/tests/gcode/linuxcnc_g52_nonpositive_p_error.ngc b/tests/gcode/linuxcnc_g52_nonpositive_p_error.ngc new file mode 100644 index 0000000..8288457 --- /dev/null +++ b/tests/gcode/linuxcnc_g52_nonpositive_p_error.ngc @@ -0,0 +1,4 @@ +G21 G90 G17 +F100 +G5.2 X1 Y1 P1 +G5.2 X2 Y2 P0 diff --git a/tests/gcode/linuxcnc_g52_p_without_xy_after_start_error.ngc b/tests/gcode/linuxcnc_g52_p_without_xy_after_start_error.ngc new file mode 100644 index 0000000..fe3ea5a --- /dev/null +++ b/tests/gcode/linuxcnc_g52_p_without_xy_after_start_error.ngc @@ -0,0 +1,4 @@ +G21 G90 G17 +F100 +G5.2 X1 Y1 P1 +G5.2 P1 diff --git a/tests/gcode/linuxcnc_g52_zero_feed_error.ngc b/tests/gcode/linuxcnc_g52_zero_feed_error.ngc new file mode 100644 index 0000000..08c383a --- /dev/null +++ b/tests/gcode/linuxcnc_g52_zero_feed_error.ngc @@ -0,0 +1,2 @@ +G21 G90 G17 +G5.2 X1 Y1 P1 diff --git a/tests/gcode/linuxcnc_g53_short_control_points_error.ngc b/tests/gcode/linuxcnc_g53_short_control_points_error.ngc new file mode 100644 index 0000000..7ef9ee7 --- /dev/null +++ b/tests/gcode/linuxcnc_g53_short_control_points_error.ngc @@ -0,0 +1,4 @@ +G21 G90 G17 +F100 +G5.2 X1 Y1 P1 +G5.3 diff --git a/tests/gcode/linuxcnc_g53_without_g52_error.ngc b/tests/gcode/linuxcnc_g53_without_g52_error.ngc new file mode 100644 index 0000000..0e536ca --- /dev/null +++ b/tests/gcode/linuxcnc_g53_without_g52_error.ngc @@ -0,0 +1,3 @@ +G21 G90 G17 +F100 +G5.3 diff --git a/tests/gcode/linuxcnc_g62_k_non_integer_error.ngc b/tests/gcode/linuxcnc_g62_k_non_integer_error.ngc new file mode 100644 index 0000000..7a04340 --- /dev/null +++ b/tests/gcode/linuxcnc_g62_k_non_integer_error.ngc @@ -0,0 +1,3 @@ +G21 G90 G17 +F100 +G6.2 X1 Y1 R1 K0.5 P3 Q1 diff --git a/tests/gcode/linuxcnc_g62_missing_p_order_error.ngc b/tests/gcode/linuxcnc_g62_missing_p_order_error.ngc new file mode 100644 index 0000000..473b4ca --- /dev/null +++ b/tests/gcode/linuxcnc_g62_missing_p_order_error.ngc @@ -0,0 +1,3 @@ +G21 G90 G17 +F100 +G6.2 X1 Y1 R1 K0 Q1 diff --git a/tests/gcode/linuxcnc_g62_missing_q_mode_error.ngc b/tests/gcode/linuxcnc_g62_missing_q_mode_error.ngc new file mode 100644 index 0000000..19eeef1 --- /dev/null +++ b/tests/gcode/linuxcnc_g62_missing_q_mode_error.ngc @@ -0,0 +1,3 @@ +G21 G90 G17 +F100 +G6.2 X1 Y1 R1 K0 P3 diff --git a/tests/gcode/linuxcnc_g62_p_non_integer_error.ngc b/tests/gcode/linuxcnc_g62_p_non_integer_error.ngc new file mode 100644 index 0000000..e7934b8 --- /dev/null +++ b/tests/gcode/linuxcnc_g62_p_non_integer_error.ngc @@ -0,0 +1,3 @@ +G21 G90 G17 +F100 +G6.2 X1 Y1 R1 K0 P3.5 Q1 diff --git a/tests/gcode/linuxcnc_g62_q_non_integer_error.ngc b/tests/gcode/linuxcnc_g62_q_non_integer_error.ngc new file mode 100644 index 0000000..8923e7d --- /dev/null +++ b/tests/gcode/linuxcnc_g62_q_non_integer_error.ngc @@ -0,0 +1,3 @@ +G21 G90 G17 +F100 +G6.2 X1 Y1 R1 K0 P3 Q1.5 diff --git a/tests/gcode/linuxcnc_g62_q_out_of_range_error.ngc b/tests/gcode/linuxcnc_g62_q_out_of_range_error.ngc new file mode 100644 index 0000000..a29a7f7 --- /dev/null +++ b/tests/gcode/linuxcnc_g62_q_out_of_range_error.ngc @@ -0,0 +1,3 @@ +G21 G90 G17 +F100 +G6.2 X1 Y1 R1 K0 P3 Q4 diff --git a/tests/gcode/linuxcnc_g62_zero_feed_error.ngc b/tests/gcode/linuxcnc_g62_zero_feed_error.ngc new file mode 100644 index 0000000..5f21280 --- /dev/null +++ b/tests/gcode/linuxcnc_g62_zero_feed_error.ngc @@ -0,0 +1,2 @@ +G21 G90 G17 +G6.2 X1 Y1 R1 K0 P3 Q1