Skip to content

fix: preserve real config data through JSON export/import (M7)#104

Merged
g4bri3lDev merged 1 commit into
OpenDisplay:mainfrom
balloob:fix/config-json-roundtrip
Jul 5, 2026
Merged

fix: preserve real config data through JSON export/import (M7)#104
g4bri3lDev merged 1 commit into
OpenDisplay:mainfrom
balloob:fix/config-json-roundtrip

Conversation

@balloob

@balloob balloob commented Jul 4, 2026

Copy link
Copy Markdown
Contributor

Summary

M7 — JSON export silently zeroed real config data (🟠)

config_to_json hardcoded display full_update_mC and reserved_pin_2..8 to "0x0", and the binary_input export omitted the 8 GPIO reserved_pins and the reserved blob (which carries the ADC-ladder thresholds and power_off_flags/power_off_hold_sec). So a binary → JSON → binary round-trip written back to a device silently zeroed real hardware pins and firmware fields.

Fix

  • Export the real reserved_pins (as reserved_pin_N) and full_update_mC.
  • Export the reserved blobs as hex (new _hex_bytes) so fields living inside them (ADC thresholds, power-off) survive without being individually modeled.
  • Import reconstructs reserved_pins from the per-pin fields and parses the reserved blob via _parse_hex_bytes, which stays backward compatible with legacy "0x0" values (parsed as all-zero bytes).

Test plan

  • uv run pytest -q → 446 passed (3 new: display pins/full_update_mC/reserved survive round-trip, binary_input pins + reserved blob survive, legacy "0x0" still parses as zeros)
  • ruff, mypy clean

🤖 Generated with Claude Code

@balloob balloob requested a review from g4bri3lDev as a code owner July 4, 2026 07:13
@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!

config_to_json hardcoded display full_update_mC and reserved_pin_2..8 to "0x0",
and the binary_input export omitted the 8 GPIO reserved_pins and the reserved
blob (which carries the ADC-ladder thresholds and power_off_flags/hold_sec). A
binary -> JSON -> binary round-trip therefore silently zeroed real hardware pins
and firmware fields.

Export the real reserved_pins and full_update_mC, and export the reserved blobs
as hex (new _hex_bytes) so unmodeled fields living inside them survive. The
import side reconstructs reserved_pins from the per-pin fields and parses the
reserved blob via _parse_hex_bytes, which stays backward compatible with legacy
"0x0" values.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JRrm95f1qNZzDM9r2SB6KW
@balloob balloob force-pushed the fix/config-json-roundtrip branch from 8f53d27 to 2c86017 Compare July 4, 2026 11:42
@g4bri3lDev g4bri3lDev merged commit 59f4160 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