feat: Support dual repeating field sets and conditional proprietary fields#396
Merged
sbender9 merged 1 commit intocanboat:masterfrom Mar 6, 2026
Merged
Conversation
Add support for PGN definitions with two repeating field sets (RepeatingFieldSet1 and RepeatingFieldSet2), used by PGN 126208 Write Fields which has separate selection pairs (list) and command pairs (list2). Skip fields with Condition "PGNIsProprietary" when the target PGN is not in a proprietary range. Previously these fields (Manufacturer Code, Reserved, Industry Code) were always written, adding 2 extra bytes that corrupted Write Fields commands for standard PGNs like 127508 (Battery Status). Tested and verified working on Victron MPPT 100/50 battery instance change via PGN 126208 Write Fields.
f265fa4 to
6d5fd33
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hi Scott,
this PR adds two related features that are needed to make PGN 126208 Write Fields (function code 5) work correctly.
Dual repeating field sets
PGN 126208 Write Fields uses two separate repeating field sets — selection pairs and command pairs. This adds support for
RepeatingFieldSet1Size/RepeatingFieldSet2Sizein both encoding (toPgn) and decoding (fromPgn), usinglistandlist2respectively.Conditional proprietary fields
Fields 3–5 of PGN 126208 (Manufacturer Code, Reserved, Industry Code) have
"Condition": "PGNIsProprietary"in the PGN definitions, meaning they should only be present when the target PGN is proprietary. Previously these fields were always included, which added 2 extra bytes that shifted everything after them and corrupted the message.For example, a Write Fields command targeting PGN 127508 (Battery Status) was producing 13 bytes instead of the correct 11, and the receiving device would just ignore it.
Real-world use case
I needed this to change battery instances on a Victron SmartSolar MPPT 100/50 via PGN 126208 Write Fields from a SignalK server. Without the fix the MPPT silently ignored the command because the message was malformed. With this fix, instance changes work correctly — tested and verified on real hardware.
Changes:
lib/utilities.ts— AddedisPGNProprietary()helperlib/toPgn.ts— Skip conditional fields for non-proprietary target PGNs, dual repeating field set supportlib/fromPgn.ts— Same conditional field skipping and dual repeating field set supporttest/pgns/126208.js— Added Write Fields test case for non-proprietary PGN (round-trip)All existing tests pass (185 passing, the 127258 Magnetic Variation failure is pre-existing on master).