Optimize XYZAC motion updates and persist power-off recovery

This commit is contained in:
2026-08-29 04:52:44 +08:00
parent a97971ea19
commit f6e545018e
17 changed files with 479 additions and 74 deletions

View File

@@ -4,6 +4,13 @@ const IO_SCHEMA = "wasm_xyzac_io.v1";
const HAL_SCHEMA = "wasm_xyzac_hal.v1";
const POSE_BYTES = 72;
const HAL_WRITE_ALLOWLIST = new Set(["motion.probe-input", "iocontrol.0.tool-prepared", "iocontrol.0.tool-changed", "spindle.0.speed-in", "spindle.0.at-speed"]);
const IO_ERROR_REASONS = Object.freeze({
[-900]: "wasm_io_invalid_argument", [-901]: "wasm_io_range_error", [-902]: "wasm_io_invalid_state",
[-903]: "wasm_io_power_required", [-904]: "wasm_io_estop_active", [-905]: "wasm_io_fault_active",
[-906]: "wasm_io_limit_active", [-907]: "wasm_io_nonfinite_value", [-908]: "wasm_io_hal_pin_error",
[-909]: "wasm_io_capacity_exceeded", [-910]: "wasm_io_busy", [-911]: "wasm_io_probe_error",
[-912]: "wasm_io_timeout", [-913]: "wasm_io_recovery_required",
});
function call(core, name, returnType, argTypes, args) {
const fn = core?.[`_${name}`] ?? core?.[name];
@@ -59,7 +66,7 @@ export class WasmXyzacIo {
if (!this.available) return { status: "blocked", code: "wasm_xyzac_io_unavailable" };
const result = call(this.core, name, "number", ["number", ...args.map(() => "number")], [this.pointer, ...args]);
this.lastError = result;
return result === 0 ? { status: "verified", command: name } : { status: "error", code: `wasm_${name}_${result}`, result };
return result === 0 ? { status: "verified", command: name } : { status: "error", code: `wasm_${name}_${result}`, result, reason: IO_ERROR_REASONS[result] ?? `wasm_${name}_${result}`, message_key: IO_ERROR_REASONS[result] ?? `wasm_${name}_${result}`, source: "linuxcnc-wasm-io" };
}
canonical() {