From 63ecbb657725d31d006f794f0ed638223b23684d Mon Sep 17 00:00:00 2001 From: cnc Date: Fri, 22 May 2026 17:42:30 +0800 Subject: [PATCH] Cover modal modes in source link tests --- docs/linuxcnc-porting.md | 1 + test-linuxcnc-source-link.sh | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/docs/linuxcnc-porting.md b/docs/linuxcnc-porting.md index d553081..f0e3bee 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 | Tool length offset `G43/G49` | covered with nonzero tool-table offset through LinuxCNC native/source backends | `tests/gcode/linuxcnc_tool_length.ngc` | | 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` | +| 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 | `tests/gcode/linuxcnc_canned_cycle.ngc` | | Coordinate offset Canon events `G10 L2`, `G10 L20`, `G92/G92.1` | covered through LinuxCNC native/source backends | `tests/gcode/linuxcnc_coordinate_offsets.ngc`, `tests/gcode/linuxcnc_coordinate_l20.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` | diff --git a/test-linuxcnc-source-link.sh b/test-linuxcnc-source-link.sh index 9ead3c5..0c3cc15 100755 --- a/test-linuxcnc-source-link.sh +++ b/test-linuxcnc-source-link.sh @@ -103,6 +103,12 @@ CNC_SIM_RS274_VAR="$var_file" \ CNC_SIM_RS274_VAR="$var_file" \ "$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_rtcp_controls.ngc \ >/tmp/cnc_sim_linuxcnc_source_rtcp_controls.json +CNC_SIM_RS274_VAR="$var_file" \ + "$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_feed_modes.ngc \ + >/tmp/cnc_sim_linuxcnc_source_feed_modes.json +CNC_SIM_RS274_VAR="$var_file" \ + "$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_motion_modes.ngc \ + >/tmp/cnc_sim_linuxcnc_source_motion_modes.json CNC_SIM_RS274_VAR="$var_file" \ "$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_tool_length.ngc \ >/tmp/cnc_sim_linuxcnc_source_tool_length.json @@ -163,6 +169,34 @@ rtcp = [event for event in controls if event["type"] == "rtcp-state"] if [(event["line"], event["tool"], event["feed"]) for event in rtcp] != [(3, 0, 0), (4, 7, 1)]: raise SystemExit("unexpected source-linked RTCP state sequence") +feed_modes = json.loads(Path("/tmp/cnc_sim_linuxcnc_source_feed_modes.json").read_text()) +feed_mode_comments = [ + (event["line"], event["reserved"]) + for event in feed_modes + if event["type"] == "comment" +] +for expected in [(2, 93), (3, 94), (4, 95)]: + if expected not in feed_mode_comments: + raise SystemExit(f"missing source-linked feed mode comment state {expected!r}") +feed_mode_events = [ + (event["line"], event["reserved"]) + for event in feed_modes + if event["type"] == "set-feed" +] +for expected in [(3, 0), (4, 0)]: + if expected not in feed_mode_events: + raise SystemExit(f"missing source-linked feed mode event {expected!r}") + +motion_modes = json.loads(Path("/tmp/cnc_sim_linuxcnc_source_motion_modes.json").read_text()) +motion_mode_states = [ + (event["line"], event["reserved"], event["feed"]) + for event in motion_modes + if event["type"] == "comment" +] +for expected in [(2, 611, 0), (3, 612, 0), (4, 640, 0.05)]: + if expected not in motion_mode_states: + raise SystemExit(f"missing source-linked motion mode state {expected!r}") + tool_length = json.loads(Path("/tmp/cnc_sim_linuxcnc_source_tool_length.json").read_text()) if not any( event["type"] == "comment" and @@ -336,6 +370,8 @@ PY echo "linuxcnc rs274 source link smoke passed (${#objects[@]} local objects)" echo "dumped /tmp/cnc_sim_linuxcnc_source_basic_mill.json" echo "dumped /tmp/cnc_sim_linuxcnc_source_rtcp_controls.json" +echo "dumped /tmp/cnc_sim_linuxcnc_source_feed_modes.json" +echo "dumped /tmp/cnc_sim_linuxcnc_source_motion_modes.json" echo "dumped /tmp/cnc_sim_linuxcnc_source_tool_length.json" echo "dumped /tmp/cnc_sim_linuxcnc_source_canned_cycle.json" echo "dumped /tmp/cnc_sim_linuxcnc_source_canned_cycles_extended.json"