feat(addressing): take the frame's kind into Decompose, refuse a PDU1 PGN with a low byte, and give the NAME its wire order - #151
Conversation
… PGN with a low byte, and give the NAME its wire order #55, the three findings. J1939Id.Decompose(uint) cannot tell an 11-bit identifier from a 29-bit one -- every 11-bit value is a valid 29-bit one with priority 0 and PDU Format 0 -- so an overload takes the frame's kind and refuses one that is not extended, and the single-argument form says so. ComposePgn silently discarded the low byte of a PDU1 PGN; SAE J1939-21 defines it as 0, so a value with it set is refused. And J1939Name owns its wire order now -- ToBytes, WriteTo, FromBytes, least significant byte first per SAE J1939-81 -- so no caller reaches for a platform-endian conversion. Mutation-checked: each of the three tests fails with its change reverted. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
#55: the incoming claim's NAME was read with BitConverter.ToUInt64, which is the host's byte order and wrong on a big-endian one. Both directions go through J1939Name's own conversion now. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
PR SummaryMedium Risk Overview
README examples, API approval snapshots, and Reviewed by Cursor Bugbot for commit fa832ba. Bugbot is set up for automated code reviews on this repo. Configure here. |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
What does this change?
Closes #55 — the three Addressing findings from the repository review.
J1939Id.Decompose(uint)cannot tell an 11-bit identifier from a 29-bit one by value, so an overload takes the frame's kind and refuses one that is not extended, and the single-argument form documents the limit.ComposePgnrefused nothing when given a PDU1 PGN with a non-zero low byte and silently discarded the byte; SAE J1939-21 defines it as 0, so such a value is refused.J1939Nameowns its wire order now (ToBytes,WriteTo,FromBytes: least significant byte first, SAE J1939-81), and the J1939 node reads and writes the NAME of an address claim through it instead ofBitConverter.ToUInt64, which is the host's byte order.The Addressing package stays dependency-free, hence
byte[]rather thanSpan<byte>for the NAME conversion.Type of change
feat— new behaviour (minor release):J1939Id.Decompose(uint, bool),J1939Name.ToBytes/WriteTo/FromBytesfix/perf— bug or performance fix (patch release): the node's NAME byte orderdocs/test/refactor/chore/ci— no release!in the title, plus aBREAKING CHANGE:footer explaining the migration) —ComposePgnnow throws for a value that was never a valid PGN; not a change to any documented behaviourChecklist
dotnet build CanKit.Pro.sln -c Releasesucceedsdotnet test CanKit.Pro.sln -c Releasepasses (net10.0, all 940)Decompose_Refuses_An_Identifier_From_A_Frame_That_Is_Not_Extended,ComposePgn_Refuses_A_Pdu1_Pgn_With_A_Nonzero_Low_Byte,J1939Name_Serializes_Least_Significant_Byte_First_And_Round_Trips; each fails with its change reverted (mutation-checked)🤖 Generated with Claude Code