Validate LinuxCNC tool length offsets

This commit is contained in:
cnc
2026-05-22 16:19:55 +08:00
parent ca03981d3f
commit 874610560a
5 changed files with 26 additions and 2 deletions

View File

@@ -101,6 +101,9 @@ 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_tool_length.ngc \
>/tmp/cnc_sim_linuxcnc_source_tool_length.json
CNC_SIM_RS274_VAR="$var_file" \
"$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_canned_cycle.ngc \
>/tmp/cnc_sim_linuxcnc_source_canned_cycle.json
@@ -147,6 +150,24 @@ 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")
tool_length = json.loads(Path("/tmp/cnc_sim_linuxcnc_source_tool_length.json").read_text())
if not any(
event["type"] == "comment" and
event["line"] == 2 and
event["reserved"] == 430 and
event["start"]["z"] == 12.5
for event in tool_length
):
raise SystemExit("missing source-linked G43 H1 tool length offset event")
if not any(
event["type"] == "comment" and
event["line"] == 3 and
event["reserved"] == 430 and
event["start"]["z"] == 0
for event in tool_length
):
raise SystemExit("missing source-linked G49 tool length clear event")
cycle = json.loads(Path("/tmp/cnc_sim_linuxcnc_source_canned_cycle.json").read_text())
motions = [event for event in cycle if event["type"] in {"rapid", "linear-feed"}]
expected_cycle = [
@@ -249,6 +270,7 @@ 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_tool_length.json"
echo "dumped /tmp/cnc_sim_linuxcnc_source_canned_cycle.json"
echo "dumped /tmp/cnc_sim_linuxcnc_source_canned_cycles_extended.json"
echo "dumped /tmp/cnc_sim_linuxcnc_source_cutter_comp.json"