Skip to content

hal: restore working homecomp example - #4337

Open
grandixximo wants to merge 2 commits into
LinuxCNC:masterfrom
grandixximo:fix/homecomp-rebuild
Open

hal: restore working homecomp example#4337
grandixximo wants to merge 2 commits into
LinuxCNC:masterfrom
grandixximo:fix/homecomp-rebuild

Conversation

@grandixximo

@grandixximo grandixximo commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Follow-up to #4329. homecomp.comp was filtered out of the build because it no longer compiled on master; the discussion on #4329 made it clear that should be fixed. This restores homecomp as a real, buildable plug-in homing module that demonstrates something useful, rather than an empty "always-homed" shell.

The default skeleton is a working homing module:

  • Creates the same per-joint hal pins the real homemod exposes: joint.N.home-sw-in, joint.N.homing, joint.N.homed, joint.N.home-state, joint.N.index-enable, for every joint seen at homing_init time. The output pins are driven once per servo period, so joint.N.homed tracks what motion actually believes.
  • Adds a module-level pin motion.allow-sim-homed (default true). With it set, all joints report homed, which is useful for bring-up on hardware without working home switches. With it cleared, each joint reports homed only while its joint.N.home-sw-in pin is true, showing how HAL inputs wire into the homing API. The flag can be flipped from a postgui or M-code without rebuilding.
  • Sizes its HAL buffer from n_joints at runtime (single hal_malloc), so the template does not depend on EMCMOT_MAX_JOINTS.
  • do_homing() returns 1 on the not-allhomed => allhomed transition, matching base_do_homing() semantics so motmod switches FREE => teleop when homing completes.

The skeleton's function signatures use opaque pointer and integer arguments, so the default path does not pull in motion.h's heavy transitive includes. The exported symbols still resolve to the names motmod calls.

The advanced HOMING_BASE path is preserved: with HOMING_BASE pointing at a checkout's src/emc/motion/homing.c, the template #includes that file with CUSTOM_HOMEMODULE defined and exposes per-joint request-custom-homing / is-custom-homing pins for users who want to override the base_* helpers. This is the original pattern from the 2.9-era homecomp, kept for completeness. Note that motion.h/homing.h are no longer exported to the halcompile include path since 82f05bc, so the custom block relies on homing.c's own quoted includes and does not include them directly.

Verified: both build modes compile clean with halcompile (zero warnings), and the skeleton was runtime-tested headless as HOMEMOD=homecomp (sim on => all homed; sim off => unhomed; sim off with all home-sw-in closed => homed again).

@grandixximo
grandixximo force-pushed the fix/homecomp-rebuild branch from a08a080 to 9f0d548 Compare August 4, 2026 06:52
Comment thread src/hal/components/homecomp.comp Outdated
@grandixximo
grandixximo force-pushed the fix/homecomp-rebuild branch 2 times, most recently from 76d079c to 2665cb7 Compare August 4, 2026 08:26
Add per-function documentation to homing.h: what each interface
function does, when motmod calls it, and return semantics.  Point to
it from the code-notes motion-controller section and from the
homecomp description so man page readers find it.
@grandixximo
grandixximo force-pushed the fix/homecomp-rebuild branch from 2665cb7 to 82cd21f Compare August 4, 2026 08:29
@grandixximo
grandixximo marked this pull request as ready for review August 4, 2026 08:35
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