Skip to content

fix(pixii): skip optional meter energy scale factor when absent - #16

Merged
frahlg merged 1 commit into
srcfl:mainfrom
tommylindgren:fix/pixii-40288-meter-energy-sf
Jul 23, 2026
Merged

frahlg merged 1 commit into
srcfl:mainfrom
tommylindgren:fix/pixii-40288-meter-energy-sf

Conversation

@tommylindgren

Copy link
Copy Markdown
Contributor

Some PowerShaper firmware returns Illegal Data Address on register
40288. Probe once during driver_init and avoid polling it so FTW's
fresh Modbus read evidence does not fail the whole driver.

Fixes #15

Summary

Pixii catalog driver (1.1.1) and FTW v2 package target (1.2.2) now probe
meter-energy scale factor register 40288 once during driver_init and skip it
during driver_poll when absent. This prevents FTW's poll-scoped Modbus
evidence from failing the whole driver when one optional register is missing.

Driver evidence

  • Driver id: pixii
  • Device make/model: Pixii PowerShaper (two units on the same site)
  • Firmware tested:
    • Affected unit: CPU1 v2.0.17, CPU2 v2.0.20 — register 40288 returns Modbus exception 0x02
    • Working unit: CPU1 v2.0.23, CPU2 v2.0.23 — register 40288 present, value 0 (no scaling)
  • Protocol/register source: SunSpec model 213 offset 53 (meter_energy_sf, absolute 40288); Pixii Modbus mapping doc 13300
  • Hardware test performed:
    • Direct Modbus TCP probe (FC 0x03) of all 37 poll registers with FTW stopped: affected unit 36/37 OK, working unit 37/37 OK
    • Live FTW site test (v1.10.5 dev, bundled drivers/pixii.lua 1.2.0 with same init-probe workaround): pixii-1 recovered from driver_poll: 1 of 37 modbus reads failed / offline to status: ok, consecutive_errors: 0
    • make test-driver ID=pixii, make package-driver ID=pixii TARGET=ftw-core, make check — all passed locally
  • Known limits:
    • Import/export Wh on firmware without 40288 use sf=0; on tested working unit 40288 also reads 0, so behaviour matches
    • Primary site metering was from a separate DSMR driver, not Pixii; dispatch-critical meter_w and phase readings are unaffected
    • Older firmware (v2.0.17/v2.0.20) appears to omit 40288; v2.0.23 exposes it

Safety

  • The driver starts read-only, or this is a separately reviewed control change.
  • Vendor signs are converted at the driver boundary.
  • Cached telemetry becomes stale instead of being re-emitted as fresh.
  • No credentials, serial numbers, private addresses or site data are included.

Package or promotion evidence

  • Public source SHA: (fill at merge time / from PR head commit)
  • Package ID and new version: com.sourceful.driver.pixii 1.2.2
  • Target matrix: ftw-core (catalog 1.1.1 + package candidate 1.2.2)
  • Material and candidate artifact SHA-256: from make package-driver ID=pixii TARGET=ftw-core output at commit time
  • HIL evidence or required: not applicable for this read-path bugfix; existing package HIL gates unchanged
  • Control enabled: false
  • Control changes include default-mode, lease-expiry and HIL evidence. (not applicable — no control changes)

Checks

  • Commits include Signed-off-by.
  • make test-driver ID=pixii
  • make package-driver ID=pixii TARGET=ftw-core
  • make check

Some PowerShaper firmware returns Illegal Data Address on register
40288. Probe once during driver_init and avoid polling it so FTW's
fresh Modbus read evidence does not fail the whole driver.

Fixes srcfl#15

Signed-off-by: Tommy Lindgren <[email protected]>
@frahlg
frahlg merged commit af0a229 into srcfl:main Jul 23, 2026
5 checks passed
frahlg added a commit that referenced this pull request Jul 25, 2026
…#17)

* fix(sungrow): stop polling SH hybrid registers on SG string inverters

SG string inverters answer the 5xxx PV registers but none of the SH
hybrid block. The driver read 13019 and its neighbours on every model,
so on an SG12RT 12 of 19 Modbus reads failed. Since the host started
counting a poll as failed when any single read fails, the whole device
went offline instead of reporting the PV it does have.

Probe each model-specific register once, then skip the addresses this
inverter does not answer, and emit the battery and meter streams only
when the registers behind them responded. Battery commands are refused
once a poll has proved the model has no battery block.

Same pattern as the Pixii fix in #16.

Signed-off-by: Fredrik Ahlgren <[email protected]>

* fix(sungrow): identify the model instead of discovering it through failures

The first version of this fix learned the register map by failing reads.
That had two faults. It still spent one failed poll per absent register
before settling, and any single timeout wrote a register off for the rest
of the session, so a glitching bus could silence the battery on a healthy
SH hybrid.

Read the device type code at 4999 instead. 0x0D and 0x0E are the SH hybrid
families; any other clean code is a string inverter, and the hybrid block
is then never read at all. The same register already backs
driver_fingerprint in the FTW baseline, so this is the identity the fleet
already trusts.

Probing remains only as a fallback for an unreadable type code, and now
takes three consecutive failures before it writes a register off.

Signed-off-by: Fredrik Ahlgren <[email protected]>

---------

Signed-off-by: Fredrik Ahlgren <[email protected]>
frahlg added a commit that referenced this pull request Jul 28, 2026
Pixii PowerShaper firmware below CPU 2.0.23 answers Modbus exception 2
on 40288 (meter_energy_sf). SolarEdge K-series inverters do not populate
the proprietary MPPT block at 40123. Both drivers caught the failure in
pcall and carried on, which is right at the Lua level — but the host
counts every failed modbus_read against the poll whether or not Lua
handled it. So both sat at "1 of N reads failed" every five seconds,
went offline on the stale-telemetry watchdog, and stopped feeding the
planner.

Both now probe once, remember an absent register and stop asking. A
restart re-probes, so a firmware update that adds the register is
picked up.

Pixii was fixed once already, in #16 for issue #15. That fix lived only
in packages/v1/pixii/targets/ftw.lua, so promoting FTW's driver in #27
reverted the catalog copy and the flap reached customer hardware again.
The tests added here run the catalog drivers, which is what the signed
channel publishes.

Editing the drivers cost them byte-identity with baselines/ftw, which
is what had exempted them from the Modbus suite. That exposed a bug in
_extract_decode_calls: it counted a nested call's comma as an argument
separator, so host.decode_i16(reg(regs, 40084)) read as two arguments
and failed a driver that was correct. It now matches parentheses and
splits only at depth zero.

Verified against the unpatched baselines/ftw copies: both read the
absent register three times over three polls, where the patched drivers
read it once.

Co-Authored-By: Claude Opus 5 <[email protected]>
Signed-off-by: Fredrik Ahlgren <[email protected]>
frahlg added a commit that referenced this pull request Jul 28, 2026
…ver (#34)

The package target carried the narrow fix from #16, which guarded
register 40288 alone. Every other scale factor it reads would flap the
poll counter the same way on firmware that omits it: measured 3 reads
of an absent 40256 over 3 polls before this change, 1 after. It now
uses the same per-address probe as the catalog driver.

One parametrised test holds both files to the rule. The package target
having its own green test, run against a copy that kept the fix, is
what let the catalog regression reach customer hardware unseen.

Also records what the audit turned up. FTW's drivers/ is generated from
this repository at the commit pinned in FTW's drivers/BUNDLED_SOURCE.json,
and merging here does not move that pin — a gateway booting offline
keeps the old driver until someone runs FTW's sync script. Neither
repository's docs said so. AGENTS.md now states where a driver change
has to land, and that a promoted driver drops its baselines/ftw
exemption the moment it is edited.

README.md claimed all 37 promoted drivers stay byte-identical to their
baseline; three no longer are, which is what fixing a driver means.
SOURCE_IMPORT.md still weighed an import decision that #27 settled.
CLAUDE.md was missing and now points at AGENTS.md.

Signed-off-by: Fredrik Ahlgren <[email protected]>
Co-authored-by: Claude Opus 5 <[email protected]>
tommylindgren pushed a commit to tommylindgren/device-drivers that referenced this pull request Aug 10, 2026
The package target carried the narrow fix from srcfl#16, which guarded
register 40288 alone. Every other scale factor it reads would flap the
poll counter the same way on firmware that omits it: measured 3 reads
of an absent 40256 over 3 polls before this change, 1 after. It now
uses the same per-address probe as the catalog driver.

One parametrised test holds both files to the rule. The package target
having its own green test, run against a copy that kept the fix, is
what let the catalog regression reach customer hardware unseen.

Also records what the audit turned up. FTW's drivers/ is generated from
this repository at the commit pinned in FTW's drivers/BUNDLED_SOURCE.json,
and merging here does not move that pin — a gateway booting offline
keeps the old driver until someone runs FTW's sync script. Neither
repository's docs said so. AGENTS.md now states where a driver change
has to land, and that a promoted driver drops its baselines/ftw
exemption the moment it is edited.

README.md claimed all 37 promoted drivers stay byte-identical to their
baseline; three no longer are, which is what fixing a driver means.
SOURCE_IMPORT.md still weighed an import decision that srcfl#27 settled.
CLAUDE.md was missing and now points at AGENTS.md.

Co-Authored-By: Claude Opus 5 <[email protected]>
Signed-off-by: Fredrik Ahlgren <[email protected]>
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.

[driver] Pixii: driver goes offline when meter energy scale factor (40288) is absent

2 participants