Preserve motion queue ABI for feed override

This commit is contained in:
2026-08-31 06:36:53 +08:00
parent 51ba923cb5
commit 6033dcd47a
4 changed files with 10 additions and 9 deletions

View File

@@ -102,10 +102,10 @@ export class WasmMotionQueue {
[...poseToArray(segment.start), ...poseToArray(segment.end), Number(segment.center?.x ?? 0), Number(segment.center?.y ?? 0), Number(segment.center?.z ?? 0), Number(segment.normal?.x ?? 0), Number(segment.normal?.y ?? 0), Number(segment.normal?.z ?? 0), Number(segment.velocity ?? 0), Number(segment.acceleration ?? 0)].forEach((value, index) => { doubles[base + index] = value; });
ints[this.command / 4 + SEGMENT_INT_OFFSET] = Number(segment.motion_type ?? 1);
ints[this.command / 4 + SEGMENT_INT_OFFSET + 1] = Number(segment.turn ?? 0);
// sim_motion_command layout is segment (216 bytes), id (4), tag (4), flags (4).
// sim_motion_command layout is segment (216 bytes), id (4), tag (4).
// Keep the WASM switchkins mode in the tag field; the C queue assigns id.
ints[this.command / 4 + SEGMENT_INT_OFFSET + 3] = Number(segment.kinematics_mode ?? segment.tag ?? 0);
ints[this.command / 4 + SEGMENT_INT_OFFSET + 4] = segment.kind === "rapid" ? 1 : 0;
const tag = Number(segment.kinematics_mode ?? segment.tag ?? 0) & 0x7fffffff;
ints[this.command / 4 + SEGMENT_INT_OFFSET + 3] = tag | (segment.kind === "rapid" ? 0x80000000 : 0);
const result = call(this.core, "sim_motion_enqueue", "number", ["number", "number", "number"], [this.queue, this.command, 0]);
return result === 0 ? { status: "verified", source_line: segment.source_line ?? null } : { status: "error", code: `wasm_motion_enqueue_${result}`, reason: MOTION_ERROR_REASONS[result] ?? `wasm_motion_enqueue_${result}`, message_key: MOTION_ERROR_REASONS[result] ?? `wasm_motion_enqueue_${result}`, source: "linuxcnc-wasm-motion" };
}