Skip to content

Fix missing high nibble in POM CV bit-write data byte#10

Merged
jaak0b merged 2 commits into
mainfrom
fix/pom-write-bit-nibble
Jun 5, 2026
Merged

Fix missing high nibble in POM CV bit-write data byte#10
jaak0b merged 2 commits into
mainfrom
fix/pom-write-bit-nibble

Conversation

@jaak0b

@jaak0b jaak0b commented Jun 5, 2026

Copy link
Copy Markdown
Owner

Fixes a frame-encoding bug in the POM bit-write commands: DB5 was built as (V?0x08:0) | PPP, omitting the high nibble.

DB5 is the DCC bit-manipulation data byte, which NMRA S-9.2.1 defines as 111K-DBBB. For a write K=1, so the high nibble must be 1111 (0xF0). Without it the decoder receives an invalid opcode and silently ignores the frame — so a raw bit write does nothing on hardware.

Fixed (same defect in both)

  • CvPomWriteBitCommand (§6.7, locomotive) — also corrects the frame emitted by the safe WritePomCvBitAsync wrapper.
  • CvPomAccessoryWriteBitCommand (§6.10, accessory) — identical bug.

DB5 is now 0xF0 | (V?0x08:0) | (PPP & 0x07).

Tests

Updated both byte-exact test fixtures (DB5 and recomputed XOR). The byte read/write and bit read paths were already correct and are unaffected. Full solution green: 710 passed.

@jaak0b jaak0b merged commit 3b9bd1e into main Jun 5, 2026
6 checks passed
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.

1 participant