Enforce LinuxCNC WASM XYZAC command authority

This commit is contained in:
2026-08-28 13:04:47 +08:00
parent 1a7995fa9b
commit 78d884bc67
43 changed files with 567 additions and 186 deletions

View File

@@ -454,6 +454,33 @@ int sim_io_set_estop(sim_io *io, uint32_t estop) {
return SIM_IO_OK;
}
int sim_io_set_power(sim_io *io, uint32_t active) {
if (!valid_io(io) || active > 1U) return SIM_IO_ERR_ARGUMENT;
if (io->state.estop) { set_last(io, SIM_IO_ERR_ESTOP); return SIM_IO_ERR_ESTOP; }
if (!active) {
io->state.ready = 0;
io->state.tool_prepare = 0;
io->state.tool_change = 0;
io->state.tool_prepared = 0;
io->state.tool_changed = 0;
io->state.tool_state = SIM_IO_TOOL_ABORTED;
for (uint32_t index = 0; index < io->state.spindle_count; ++index) {
io->state.spindles[index].command_rpm = 0.0;
io->state.spindles[index].enabled = 0;
io->state.spindles[index].brake = 1;
}
} else {
if (io->state.fault || io->state.toolchanger_fault) { set_last(io, SIM_IO_ERR_FAULT); return SIM_IO_ERR_FAULT; }
if (!spindle_stopped(io)) { set_last(io, SIM_IO_ERR_BUSY); return SIM_IO_ERR_BUSY; }
io->state.ready = 1;
io->state.recovery_epoch += 1;
io->state.tool_state = SIM_IO_TOOL_IDLE;
}
set_last(io, SIM_IO_OK);
mirror_pins(io);
return SIM_IO_OK;
}
int sim_io_recover(sim_io *io) {
if (!valid_io(io)) return SIM_IO_ERR_ARGUMENT;
if (io->state.estop) return SIM_IO_ERR_ESTOP;