Skip to content

fix(saj-emanager): read the eManager again after a silent start (0.1.3) - #317

Open
frahlg wants to merge 1 commit into
mainfrom
fix/saj-emanager-wake
Open

frahlg wants to merge 1 commit into
mainfrom
fix/saj-emanager-wake

Conversation

@frahlg

@frahlg frahlg commented Dec 5, 2026

Copy link
Copy Markdown
Member

Problem

saj-emanager 0.1.2 asked the summary block (0x848A) on every poll, so power came back once the controller answered. The device count (0x4A00), the serial slots (0x4A01), the phase block (0x849E) and the energy counters (0x8500) went through probe_read, which leaves a block alone until restart after three misses. The device count and the serial were also read first in every poll.

A controller that was off, restarting or held by another Modbus client when FTW started used up every try on those blocks while answering nothing. Once it answered, the driver sent PV, battery and grid power but no serial, no phase values and no energy counters until FTW restarted it. With no device count, apply_phases no longer divided a summed phase voltage or frequency, so a three-inverter plant that sums them could report 150 Hz for the whole run.

Change

  • A miss counts only in a poll where another read answered, so a silent controller uses up no tries. A block that misses three times on a controller that does answer is asked again every five minutes instead of never.
  • The summary counts as an answer. It is still asked on every poll, and when it does not answer nothing goes out.
  • The device count is read once the summary has answered, before the phase block it scales. The serial slots are read last, after the streams.
  • driver_cleanup resets the new poll state.

Test evidence

  • test_saj-emanager_wakes.py, nine tests with a three-inverter fixture (saj-emanager_wakes_fixture.lua). Eight fail on 0.1.2 and all pass on 0.1.3:
    • test_wakes_after_silence.lua (shared with the other PRs in this series): silent from start-up, silent mid-session, each block refused six times;
    • ten silent polls, then serial, phases, energy and power on the first poll that answers;
    • a summed phase voltage and frequency divided right after a silent start;
    • no identity, phase or energy read while the summary does not answer;
    • the device count, serial slots, phase block and energy counters asked again within five minutes after three refusals.
    • The ninth, fields left out when the phase and energy blocks do not answer, passes on 0.1.2 too.
  • test_saj-emanager.py passes unchanged (20 tests).
  • make test-driver ID=saj-emanager: 68 passed, 15 skipped.
  • make absent-register-report ID=saj-emanager: 0x4A00, 0x849E and 0x8500 settle; the summary 0x848A emits nothing.
  • make invented-number-report ID=saj-emanager: none. The driver was not in the baseline.
  • make check: 5583 passed, 927 skipped.

Not yet verified

  • No hardware run; the driver has never run on an eManager. The case needs one that is off or held by another client when FTW starts.
  • Left as it was: the device count and serial slots are still read on every poll, as before. A summary that answers with a sentinel in a power word still sends that stream without its power (test_int32_sentinel_is_not_a_power asserts this for the meter); the owner may want such a stream left out.
  • CHANGELOG.md and drivers/tests/lua_harness/test_wakes_after_silence.lua are shared with the other PRs in this series; whichever merges later needs a rebase there.
  • After merge, FTW's pin in drivers/BUNDLED_SOURCE.json has to move.

🤖 Generated with Claude Code

The summary block was asked on every poll, so power came back once the
controller answered. The device count, the serial slots, the phase block
and the energy counters went through a guard that left a block alone until
restart after three misses. A controller that was off, restarting or held
by another Modbus client at start-up used up every try, and the driver
then sent no serial, no phase values and no energy counters until FTW
restarted it. With no device count it also stopped dividing a summed phase
voltage or frequency.

A miss now counts only in a poll where another read answered, and a block
that misses three times on a controller that does answer is asked again
every five minutes. The summary counts as an answer. The device count is
read once the summary has answered, before the phase block it scales, and
the serial slots are read last.

test_saj-emanager_wakes.py fails on 0.1.2 (8 of 9 cases; the ninth checks
fields left out, which 0.1.2 already did) and passes on 0.1.3.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Fredrik Ahlgren <fredrik@sourceful-labs.com>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Dec 5, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-12-05T04:31:02.790403Z 63e6316 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

This branch has not been deployed

No deployments
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