Skip to content

fix: surface device error frames with typed exceptions (§4)#108

Merged
g4bri3lDev merged 1 commit into
OpenDisplay:mainfrom
balloob:fix/protocol-error-frames
Jul 5, 2026
Merged

fix: surface device error frames with typed exceptions (§4)#108
g4bri3lDev merged 1 commit into
OpenDisplay:mainfrom
balloob:fix/protocol-error-frames

Conversation

@balloob

@balloob balloob commented Jul 4, 2026

Copy link
Copy Markdown
Contributor

Summary

Two §4-minor fixes for graceful handling of firmware error frames.

  • unpack_command_code / check_response_type raised a bare struct.error on <2-byte frames and a ValueError on unknown command codes. The firmware's 2-byte {0xFF,0xFF} compressed-failure frame and 4-byte NACKs hit exactly this in the upload loop, crashing with the wrong exception type. Both are now wrapped in InvalidResponseError.
  • interrogate() misread the READ_CONFIG "no config" error frame {0xFF,0x40,0x00,0x00} as a zero-length config (its 0x0000 length field). It now detects that frame and raises a clear ProtocolError.

Test plan

  • uv run pytest -q → 446 passed (3 new: short frame → InvalidResponseError, unknown code {0xFF,0xFF} → InvalidResponseError, interrogate no-config frame → ProtocolError)
  • ruff, mypy clean

🤖 Generated with Claude Code

@balloob balloob requested a review from g4bri3lDev as a code owner July 4, 2026 07:23
@codecov

codecov Bot commented Jul 4, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

- unpack_command_code / check_response_type raised a bare struct.error on
  <2-byte frames and ValueError on unknown command codes. The firmware's
  2-byte {0xFF,0xFF} compressed-failure frame and 4-byte NACKs hit exactly
  this in the upload loop, crashing with the wrong exception type. Wrap both
  in InvalidResponseError.
- interrogate() misread the READ_CONFIG "no config" error frame
  {0xFF,0x40,0x00,0x00} as a zero-length config (its 0x0000 length field).
  Detect the frame and raise a clear ProtocolError instead.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JRrm95f1qNZzDM9r2SB6KW
@balloob balloob force-pushed the fix/protocol-error-frames branch from 5b4e89e to 63a28f5 Compare July 4, 2026 11:42
@g4bri3lDev g4bri3lDev merged commit 376d118 into OpenDisplay:main Jul 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.

2 participants