Skip to content

Safe POM CV bit read/write#9

Merged
jaak0b merged 1 commit into
mainfrom
feature/safe-pom-bit
Jun 5, 2026
Merged

Safe POM CV bit read/write#9
jaak0b merged 1 commit into
mainfrom
feature/safe-pom-bit

Conversation

@jaak0b

@jaak0b jaak0b commented Jun 5, 2026

Copy link
Copy Markdown
Owner

Adds safe (retrying, deadline-bounded) read/write for a single CV bit on the main track (POM), building on the safe CV programming merged in #8.

New API on IZ21CommandStation

  • WritePomCvBitAsync(loco, cv, bitPosition, bitValue, timeout) — writes one CV bit (LAN_X_CV_POM_WRITE_BIT, §6.7). Since a POM write returns no acknowledgement, it verifies by reading the CV byte back (LAN_X_CV_POM_READ_BYTE, §6.8, RailCom) and retrying until the target bit matches or the deadline elapses.
  • ReadPomCvBitAsync(loco, cv, bitPosition, timeout) → bool — reads the CV byte back and returns the target bit.

Notes

  • Reuses the hardened CV plumbing: the _cvLock serialization, Task.WaitAsync deadline bounding, OCE→timeout mapping, dispose handling, CvRetryDelay backoff, and short-circuit abort.
  • bitPosition is validated to 0–7 (ArgumentOutOfRangeException otherwise).
  • Requires RailCom for the read-back (same constraint as the POM byte write).

Tests

8 new unit tests (write-bit match / retry / timeout / invalid position; read-bit set / clear / timeout / invalid position). Full solution green: 710 passed, hardware smoke tests skipped.

@jaak0b jaak0b merged commit cbf4473 into main Jun 5, 2026
8 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