Skip to content

fix(canopen): can_bridge_example never initialized its TWAI node before START - #803

Merged
finger563 merged 1 commit into
mainfrom
fix/can-bridge-initialize-twai
Sep 21, 2026
Merged

finger563 merged 1 commit into
mainfrom
fix/can-bridge-initialize-twai

Conversation

@finger563

Copy link
Copy Markdown
Contributor

Summary

Every START from the CAN console / DS402 panel failed with start failed: Not owner. start_bus() in can_bridge_example.cpp constructed the espp::Twai and called start() without ever calling initialize(), so the node was never created; Twai::start() on an uninitialized node returns operation_not_permitted, and newlib's message for that errno is "Not owner". This has been the case since the example landed in #748 (initialize() has always been a separate step on espp::Twai).

Fix: call initialize() before start(). auto_start stays off so start() still runs explicitly and the host gets its own error code if enabling the node fails.

Test plan

  • components/canopen/can_bridge_example builds (esp32s3, manager on)
  • Hardware: START from the CAN console / DS402 panel brings the bus up and frames flow

🤖 Generated with Claude Code

https://claude.ai/code/session_01DFjjnq3XCTRAXENSxsCxJU

…re START

start_bus() constructed the espp::Twai and called start() without
initialize(), so the node was never created and start() returned
operation_not_permitted -- reported to the host as "start failed: Not owner"
(newlib's EPERM string). Call initialize() first; start() still runs
explicitly so the host gets a precise error code.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DFjjnq3XCTRAXENSxsCxJU
Copilot AI lite review requested due to automatic review settings September 21, 2026 14:44
@github-actions

Copy link
Copy Markdown

✅Static analysis result - no issues found! ✅

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟢 Approval recommended

The change matches the Twai lifecycle contract and resolves the reported startup failure.

Review effort: Lite
Findings: None

What changed in this PR

Fixes CAN bridge startup by initializing the TWAI node before explicitly starting it.

Changes:

  • Calls initialize() before start().
  • Preserves explicit start error reporting.
File Description
components/​canopen/​can_bridge_example/​main/​can_bridge_example.cpp Corrects TWAI initialization order.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@finger563
finger563 merged commit 919b386 into main Sep 21, 2026
166 checks passed
@finger563
finger563 deleted the fix/can-bridge-initialize-twai branch September 21, 2026 15:05
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