From 0bce16e4011996bff32de7e2debf6fbca5c76c9d Mon Sep 17 00:00:00 2001 From: Luca Toniolo <10792599+grandixximo@users.noreply.github.com> Date: Tue, 24 Nov 2026 01:08:51 +1100 Subject: [PATCH 1/2] interp: let go of the kinematics HAL component at exit The interpreter attaches a HAL component, `interp.`, the first time it evaluates the kinematics, and releases it only in its destructor. Task exits without destroying the interpreter, so the component outlived milltask and the linuxcnc script's shutdown waited out its 2 s loop for it. Interp::exit() now releases it; a later use loads it again. tests/ptp-robot, which evaluates the kinematics, takes 1.9 s instead of 3.9 s. --- src/emc/rs274ngc/rs274ngc_pre.cc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/emc/rs274ngc/rs274ngc_pre.cc b/src/emc/rs274ngc/rs274ngc_pre.cc index 8ab946e80b0..2e9c2a04990 100644 --- a/src/emc/rs274ngc/rs274ngc_pre.cc +++ b/src/emc/rs274ngc/rs274ngc_pre.cc @@ -812,6 +812,10 @@ int Interp::exit() } } + // task exits without destroying the interpreter: let go of the HAL + // component the kinematics was evaluated through, or it outlives task + // and the shutdown waits for it; the next use loads it again + kins_release(&_setup); return INTERP_OK; } From 140edfd82d0b1d27e9139e5014cda0be07f3efba Mon Sep 17 00:00:00 2001 From: Luca Toniolo <10792599+grandixximo@users.noreply.github.com> Date: Tue, 24 Nov 2026 01:29:29 +1100 Subject: [PATCH 2/2] interp: mark no kinematics HAL component with -1, not 0 HAL component id 0 is valid, so 0 cannot stand for "none". Start kins_comp_id at -1 and release any id >= 0. --- src/emc/rs274ngc/interp_setup.cc | 2 +- src/emc/rs274ngc/interp_workplane.cc | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/emc/rs274ngc/interp_setup.cc b/src/emc/rs274ngc/interp_setup.cc index 80021e5a4b7..a0b27f6132f 100644 --- a/src/emc/rs274ngc/interp_setup.cc +++ b/src/emc/rs274ngc/interp_setup.cc @@ -117,7 +117,7 @@ setup::setup() : orient_valid(false), orient_pose{0.0, 0.0, 0.0, 0.0, 0.0, 0.0}, kins_ctx(nullptr), - kins_comp_id(0), + kins_comp_id(-1), kins_module{}, kins_joints(0), kins_angular_joints(0), diff --git a/src/emc/rs274ngc/interp_workplane.cc b/src/emc/rs274ngc/interp_workplane.cc index d1e626df12f..21cb5a57585 100644 --- a/src/emc/rs274ngc/interp_workplane.cc +++ b/src/emc/rs274ngc/interp_workplane.cc @@ -652,9 +652,9 @@ void Interp::kins_release(setup_pointer s) kinematicsUserFree(KINS_CTX(s)); s->kins_ctx = NULL; } - if (s->kins_comp_id > 0) { + if (s->kins_comp_id >= 0) { hal_exit(s->kins_comp_id); - s->kins_comp_id = 0; + s->kins_comp_id = -1; } }