Skip to content

fix: release EtherCAT master in EcMaster destructor#221

Open
apajon wants to merge 1 commit intoICube-Robotics:jazzyfrom
apajon:fix/release-ecmaster-destructor
Open

fix: release EtherCAT master in EcMaster destructor#221
apajon wants to merge 1 commit intoICube-Robotics:jazzyfrom
apajon:fix/release-ecmaster-destructor

Conversation

@apajon
Copy link
Copy Markdown

@apajon apajon commented Apr 14, 2026

Problem

The current jazzy branch correctly defers EcMaster initialization, so multi-master setups using master_id are already supported.

However, EcMaster does not explicitly release the IgH master in its destructor. This can leave the master reserved after shutdown and may interfere with clean restart or re-acquisition.

Solution

Add an explicit ecrt_release_master(master_) call in ~EcMaster():

if (master_ != NULL) {
  ecrt_release_master(master_);
  master_ = NULL;
}

This ensures proper cleanup and symmetry with ecrt_request_master().

Impact

  • improves shutdown behavior
  • avoids master remaining reserved after process exit
  • no impact on runtime behavior

Why this PR

This PR intentionally focuses on a minimal and isolated fix for proper resource cleanup in the current jazzy branch.

Testing

Validated in a real setup (ROS2 Jazzy / Ubuntu 24.04) with repeated startup / shutdown cycles on a multi-bus EtherCAT configuration.

Call ecrt_release_master() in ~EcMaster() to properly release the kernel
EtherCAT master device. Without this, the master remains locked after the
process exits, preventing re-initialization on restart without unloading
the kernel module.

This is especially critical in multi-master setups where multiple
EcMaster instances coexist.
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.

1 participant