Skip to content

feat: Support dual repeating field sets and conditional proprietary fields#396

Merged
sbender9 merged 1 commit intocanboat:masterfrom
dirkwa:dual-repeating-field-sets
Mar 6, 2026
Merged

feat: Support dual repeating field sets and conditional proprietary fields#396
sbender9 merged 1 commit intocanboat:masterfrom
dirkwa:dual-repeating-field-sets

Conversation

@dirkwa
Copy link
Contributor

@dirkwa dirkwa commented Feb 23, 2026

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 / RepeatingFieldSet2Size in both encoding (toPgn) and decoding (fromPgn), using list and list2 respectively.

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 — Added isPGNProprietary() helper
  • lib/toPgn.ts — Skip conditional fields for non-proprietary target PGNs, dual repeating field set support
  • lib/fromPgn.ts — Same conditional field skipping and dual repeating field set support
  • test/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).

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.
@dirkwa dirkwa force-pushed the dual-repeating-field-sets branch from f265fa4 to 6d5fd33 Compare February 23, 2026 22:26
@sbender9 sbender9 added fix Something isn't working feature and removed fix Something isn't working labels Mar 6, 2026
@sbender9 sbender9 merged commit fa9dd9e into canboat:master Mar 6, 2026
6 of 8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants