From 60745adeef06841bcd322b4139f79c86fa7e0696 Mon Sep 17 00:00:00 2001 From: cnc Date: Fri, 5 Jun 2026 09:59:06 +0800 Subject: [PATCH] =?UTF-8?q?=E6=89=A7=E8=A1=8C=20AGENTS=20align-linuxcnc=20?= =?UTF-8?q?=E5=8A=A0=E9=80=9F=E8=A7=84=E5=88=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 结论:补强 WASM tooldata 可执行探针,依据 LinuxCNC src/emc/tooldata/tooldata_mmap.cc 非随机刀库 T0 查找优先返回 pocket 0 的源行为。验证通过:./test-linuxcnc-wasm-tooldata-link.sh、./test-native.sh、./test-linuxcnc-source-link.sh。 --- .../tooldata/tooldata_probe_main.cc | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/core/wasm_shims/tooldata/tooldata_probe_main.cc b/core/wasm_shims/tooldata/tooldata_probe_main.cc index 506aa70..3e36a66 100644 --- a/core/wasm_shims/tooldata/tooldata_probe_main.cc +++ b/core/wasm_shims/tooldata/tooldata_probe_main.cc @@ -84,6 +84,35 @@ int main() { return 45; } + const pid_t nonrandom_t0_child = fork(); + if (nonrandom_t0_child < 0) { + return 64; + } + if (nonrandom_t0_child == 0) { + if (tool_mmap_creator(nullptr, 0) != 0) { + _exit(65); + } + CANON_TOOL_TABLE nonrandom_t0 = tooldata_entry_init(); + nonrandom_t0.toolno = 0; + nonrandom_t0.pocketno = 12; + if (tooldata_put(nonrandom_t0, 12) == IDX_FAIL) { + _exit(66); + } + // LinuxCNC src/emc/tooldata/tooldata_mmap.cc returns pocket 0 for T0 + // before scanning table entries when the toolchanger is not random. + if (tooldata_find_index_for_tool(0) != 0) { + _exit(67); + } + _exit(0); + } + int nonrandom_t0_status = 0; + if (waitpid(nonrandom_t0_child, &nonrandom_t0_status, 0) != nonrandom_t0_child) { + return 68; + } + if (!WIFEXITED(nonrandom_t0_status) || WEXITSTATUS(nonrandom_t0_status) != 0) { + return 69; + } + if (tool_mmap_user() != -1) { return 25; }