Skip to content

fix(canopen): report a short classic upload, refuse a long one, stop reporting reserved heartbeat states as boot-up - #265

Merged
dborgards merged 5 commits into
mainfrom
fix/canopen-sync-heartbeat-upload-size
Oct 3, 2026
Merged

dborgards merged 5 commits into
mainfrom
fix/canopen-sync-heartbeat-upload-size

Conversation

@dborgards

Copy link
Copy Markdown
Owner

What does this change?

Three CANopen findings from the deep review that were filed as decision issues; decided here on spec and best practice:

Closes #253, closes #254, closes #255.

Type of change

  • feat — new behaviour (minor release)
  • fix / perf — bug or performance fix (patch release)
  • docs / test / refactor / chore / ci — no release
  • Breaking change (! in the title, plus a BREAKING CHANGE: footer explaining the migration)

Checklist

  • dotnet build CanKit.Pro.sln -c Release succeeds (with -p:CI=true)
  • dotnet test CanKit.Pro.sln -c Release passes (net10.0; net48 only runs in CI)
  • Public API changes are documented with XML comments
  • New behaviour is covered by a test
  • The requirement or ADR this relates to is referenced (FR-CO-002/003, FR-CO-008/009, FR-CO-022)

Mutation checks: removing the over-length abort, removing the shortfall report, decoding reserved bytes as Initializing, and reporting them from the guarding path each fail the matching new test. #254 is documentation only and has no test.

🤖 Generated with Claude Code

…reporting reserved heartbeat states as boot-up

#253: the classic upload client now aborts with 0607 0012h when the server sends more than it
announced (as the server's receive path and the block-upload client do), and reports through
BackgroundExceptionOccurred when it sends fewer; the shorter data is still returned.

#255: a heartbeat or guarding state byte that CiA 301 reserves is no longer raised as
HeartbeatReceived / NodeGuardingReceived with State = Initializing, which read as a boot-up.
It still counts as a sign of life and is still recorded for the NMT master.

#254: SendSyncAsync is documented as the raw send it is (not gated by NMT state or bit 30 of
1005h); the periodic producer is the gated one.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@cursor

cursor Bot commented Oct 3, 2026 •

Copy link
Copy Markdown

PR Summary

Medium Risk
Changes SDO upload failure modes and heartbeat/guarding event visibility; callers may see new aborts, background exceptions, or fewer heartbeat events, but wire handling and liveness tracking remain largely intact.

Overview
This PR tightens CANopen protocol handling in three areas from review issues #253, #255, and #254.

Classic segmented SDO upload (#253) — The client now remembers the server’s indicated size from the upload-init response. Receiving more bytes than announced aborts with LengthTooHigh (checked before MaxSdoTransferBytes, so over-announcement is distinguished from out-of-memory). Receiving fewer bytes still completes the transfer with the delivered payload, but raises BackgroundExceptionOccurred with a transport exception describing the shortfall.

Heartbeat and node guarding (#255) — Shared TryDecodeHeartbeatState replaces inline switches: CiA 301 reserved state bytes no longer surface as Initializing (which looked like a false boot-up). Invalid frames still refresh liveness / NMT tracking; HeartbeatReceived and NodeGuardingReceived fire only for reportable states (boot-up remains 0x00; 0x80 is excluded).

SYNC API clarity (#254) — Documentation only: SendSyncAsync is described as a raw one-shot send, not subject to NMT Stopped or bit 30 of 1005h, with a matching README Table 37 note. Behaviour is unchanged.

Tests cover upload length enforcement, shortfall reporting, and reserved heartbeat/guarding bytes.

Reviewed by Cursor Bugbot for commit 48c6cbe. Bugbot is set up for automated code reviews on this repo. Configure here.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 3, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-03T09:22:43.900184Z 8ff03eb New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8af66cc298

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/CanKit.Pro.CANopen/CanOpenNode.cs Outdated
@codecov

codecov Bot commented Oct 3, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 124130a79b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/CanKit.Pro.CANopen/CanOpenNode.NodeGuarding.cs Outdated
…asure the reserved-state tests on all events

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 43851c7ad2

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/CanKit.Pro.CANopen/CanOpenNode.cs
…the transfer cap

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8ff03eb5c6

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/CanKit.Pro.CANopen/CanOpenNode.cs Outdated
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@dborgards
dborgards merged commit 249fa43 into main Oct 3, 2026
14 checks passed
@dborgards
dborgards deleted the fix/canopen-sync-heartbeat-upload-size branch October 3, 2026 10:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant