Skip to content

interp: G43.4 and G49 as spellings over the kinematics switch - #4548

Open
grandixximo wants to merge 2 commits into
LinuxCNC:masterfrom
grandixximo:g434-interp
Open

grandixximo wants to merge 2 commits into
LinuxCNC:masterfrom
grandixximo:g434-interp

Conversation

@grandixximo

@grandixximo grandixximo commented Sep 15, 2026

Copy link
Copy Markdown
Contributor

G43.4 is G43 on the module's working kinematics: it switches to the type the module declares KINSTYPE_PRIMARY, then applies the offset, as if the switch line had run and drained. G49 clears the offset and drops to the identity type, but only while the offset in effect is still G43.4's: a G12.1, G13.1 or plain G43 in between means the program took the kinematics over and G49 leaves it alone. A switchable module without a primary rejects G43.4 at read time; without an identity it keeps the plain cancel; with no kinematics attached (sai, the preview) both are plain. Already on the target type there is no switch and no drain.

The switch inside G49 exposed a latent deadlock: the startup code runs at task init, before the main loop can service INTERP_EXECUTE_FINISH, so a switch requested there waited forever, as G12.1 in the startup code already did. Both now queue the switch without the wait while the startup code runs; no motion exists yet and the switch lands before the first move.

First commit: kinematics.h gets extern "C" guards, and its include guard, which closed before the trt declarations, closes at the end of the file.

tests/kins-switch walks G43.4, G49, G43 and G12.1 through the cases; docs in g-code.adoc and switchkins.adoc. Part of the plan in #4374.

Comment thread src/emc/nml_intf/emc_nml.hh Outdated
Comment thread src/emc/rs274ngc/interp_write.cc
…nd of the file

The definitions are C and the header had no linkage guards, so the first C++ include of it, emc_nml.hh in many translation units, gave the declarations C++ linkage and references to the C definitions (toolFrameInWork, the TRT tables) no longer link. The header now wraps its declarations in extern "C" for a C++ includer, as a C header does.

Its include guard also closed before the trt declarations at the end of the file, so a second include, which motion.h and emc_nml.hh together make, declared trtKinematicsSetup and the xyzac and xyzbc entry points twice. The guard now closes at the end of the file.
G43.4 is G43 on the module's working kinematics: it switches to the kinstype declared KINSTYPE_PRIMARY, then applies the offset, as if the switch line had run and drained. G49 clears the offset and drops to the identity kinstype, but only when the offset in effect is still G43.4's: a G12.1 or G13.1 in between, or a plain G43, means the program took the kinematics over and G49 leaves it alone. A switchable module without a primary rejects G43.4 at read time; without an identity it keeps the plain cancel; with no kinematics attached (sai, preview) both are plain. Already on the target kinstype there is no switch and no drain. The modal group 8 label follows the kinstype motion reports, which is the only authority, and a flag value of -1, "no information", matches every flag.

The switch inside G49 exposed a latent deadlock: the startup code runs at task init, before the main loop can service INTERP_EXECUTE_FINISH, so a switch requested there waited forever, as G12.1 in the startup code did. Both now queue the switch without the wait while the startup code runs; no motion exists yet and the switch lands before the first move.

tests/kins-switch walks G43.4, G49, G43 and G12.1 through the cases; docs in g-code.adoc and switchkins.adoc.
@grandixximo

Copy link
Copy Markdown
Contributor Author

Moved: kinematics.h carries its own extern "C" guards now, emc_nml.hh includes it plainly. Force-pushed.

interp_write.cc wants the KINSTYPE_ values, as interp_convert.cc already does on master. If you want those in a header of their own, I split them out.

@BsAtHome

Copy link
Copy Markdown
Contributor

Great. We may also want to discuss the kinematics.h contents, but that can wait. It does seem to contain very specific information and here I was thinking that kinematics/switchable kinematics was a simple loadable module...

@grandixximo

Copy link
Copy Markdown
Contributor Author

Agreed. What is specific in there (userk, the trt block, the parms struct) is module-side sharing that leaked into the interface header. The parameter block work that follows makes every module describe itself, and I will split the file there: kinematics.h keeps what motion and the interpreter call, the module-side helpers move out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants