Skip to content

rs485_bridge: a framing count of zero proves nothing about the wiring - #21

Merged
aphelps-claude-bot merged 1 commit into
mainfrom
rs485-framing-counter-caveat
Aug 28, 2026
Merged

aphelps-claude-bot merged 1 commit into
mainfrom
rs485-framing-counter-caveat

Conversation

@aphelps-claude-bot

Copy link
Copy Markdown
Collaborator

Documentation only — no code change.

What this records

Every errorCount_++ in RS485_non_blocking.cpp sits in the default: arm behind if (!haveSTX_) break;. Nothing is counted until a valid STX byte has been seen. Therefore:

  • a swapped A/B pair delivers inverted bytes that essentially never match STX → the receiver never starts a frame → counter stays at 0;
  • a disconnected bus delivers no bytes → counter stays at 0;
  • a perfectly idle healthy bus → counter stays at 0.

All three are indistinguishable by that counter.

Why it's worth a doc change

The failure mode is reading framing errors: 0 as evidence the wiring is good and looking elsewhere — precisely when the wiring is the problem. This is a caveat that reads as reassuring and isn't.

Provenance

Found at the bench on 2026-08-16, on hardware whose A/B pair had to be swapped at one end. Then confirmed by reading the state machine, rather than left as an inference from the symptom — the if (!haveSTX_) break; guard is the mechanism, not a guess about it.

The note also records what does diagnose polarity, so the caveat isn't purely negative: per-wire DC averaging. With 0x55 streaming, a driven pair reads ~1.6 V mid-rail on both lines, and matching voltages end-to-end identify which wire is which.

Context

This was sitting uncommitted in the working tree and is not on main — it surfaced while syncing the repo onto current main, and would have been lost. Filing it rather than discarding it, since the RS485 bring-up it applies to is still pending.

Needs a human review — this description is bot review input, not an approval.

🤖 Generated with Claude Code

Documents a bench finding that is easy to get backwards and expensive to get
backwards while debugging a silent bus.

Every `errorCount_++` in RS485_non_blocking.cpp sits in the `default:` arm
behind `if (!haveSTX_) break;`, so nothing is counted until a valid STX byte
has been seen. A swapped A/B pair delivers inverted bytes that essentially
never match STX, so the receiver never starts a frame and the counter stays
at 0. A disconnected bus delivers no bytes and also stays at 0. Both are
indistinguishable from a perfectly idle healthy bus.

The failure mode this prevents: reading "framing errors: 0" as evidence the
wiring is good, and looking elsewhere.

Found at the bench 2026-08-16 on hardware whose A/B had to be swapped, then
confirmed by reading the state machine rather than inferred from the symptom.
Also records what DOES work for polarity: per-wire DC averaging, since with
0x55 streaming a driven pair reads ~1.6V mid-rail on both lines and matching
voltages end-to-end identify each wire.

Documentation only; no code change.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@aphelps-claude-bot
aphelps-claude-bot merged commit eb14ddb into main Aug 28, 2026
52 checks passed
@aphelps-claude-bot
aphelps-claude-bot deleted the rs485-framing-counter-caveat branch August 28, 2026 01:04
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.

2 participants