Skip to content

Recover Waveshare transport after acquisition failures - #43

Merged
Hrabovszki1023 merged 5 commits into
mainfrom
codex/fix-issue-42
Aug 6, 2026
Merged

Hrabovszki1023 merged 5 commits into
mainfrom
codex/fix-issue-42

Conversation

@Hrabovszki1023

@Hrabovszki1023 Hrabovszki1023 commented Jul 27, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • reconnect the Waveshare TCP transport automatically before the next regular exchange after timeout, EOF, reset, protocol or network failure
  • reject a $$-framed console response that lacks the required final Command completed successfully line inside the exchange boundary
  • use exponential reconnect backoff from 1 to 30 seconds and reset it only after a successful exchange
  • never replay the failed console command automatically
  • log acquisition exception type/message and group/module context without logging complete console payloads
  • document the exact v0.1 reconnect contract

Production failures addressed

Permanent disconnect

A healthy five-module US2000/US2000C installation entered a permanent degraded state after one exchange failure. The Waveshare port remained reachable, MQTT and HTTP remained healthy, but all subsequent polling failed until the container was restarted. Code inspection confirmed that the transport disconnected after the first failure and no path connected it again.

Framed but incomplete response on six modules

The first Issue #42 branch was deployed to the real installation after expansion to six modules / 90 cells. Inventory, all module details, all cells and MQTT remained valid, but pwrsys failed almost continuously with occasional successful intervals:

PwrSysParserError: final non-empty payload line must be 'Command completed successfully'

The response contained the $$ end marker, so the transport considered it successful and did not activate recovery. Validation now occurs inside the exchange callback; a missing success line invalidates the connection and the next regular command reconnects using the existing bounded backoff.

Verification

  • PYTHONPATH=src python -m pytest — 214 passed
  • python -m ruff check . — passed
  • python -m mypy src tests — passed
  • git diff --check — passed
  • controlled TCP tests cover timeout, EOF, connection reset, framed-but-incomplete responses, failed reconnect, bounded backoff and successful recovery
  • regression test uses a six-module-length response and verifies that the failed command is not automatically replayed
  • Docker/Compose real-hardware retest required before merge

Closes #42

@Hrabovszki1023
Hrabovszki1023 marked this pull request as ready for review July 27, 2026 10:50
# Conflicts:
#	src/pylontech_console/framing/console.py
#	src/pylontech_console/transport/tcp.py
#	tests/integration/test_console_exchange.py
#	tests/unit/transport/test_tcp.py
@Hrabovszki1023
Hrabovszki1023 merged commit 54c5831 into main Aug 6, 2026
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.

Reconnect Waveshare transport automatically after persistent acquisition failure

1 participant