Repository navigation
Conversation
Signed-off-by: Marcus Murwall <[email protected]>
miravoss26
left a comment
There was a problem hiding this comment.
Read the diff. Same shape as #702 and just as clean: read_sf caches a per-address sf_supported, so a scale-factor register returning exception-2 (Pixii 40288 meter_energy_sf) is probed once, cached absent, and skipped after that, keeping the failed-read counter clean. Fallback stays SF=0 (x1), same as today.
- One edge, a touch sharper here than in #702: an address locks to
falseon the first failed read, and a cached-absent SF returns 0, i.e. x1 scaling. If a supported SF register (real value non-zero, say SF=-2 for x0.01) missed on a transient first probe, that metric would mis-scale until restart rather than just going absent. Low odds (with the link up, an SF miss is almost certainly a real exception-2), but the failure mode is a wrong number, not a missing one, so it's worth being deliberate. 2 or 3 consecutive misses before locking removes it. - Security: nothing flagged. No secrets, no new deps, existing host APIs only.
No CI attached that I can see. Safe to merge from my read once the driver test run is confirmed green. Not in my allowlist, so a human merges.
|
Thanks @murwall — the diagnosis here is exactly right, and the register-by-register probe that pinned it to 40288 alone is what made the fix obvious. Carried over verbatim in srcfl/device-drivers#33, with you credited. Moving it because That is not a hypothetical — it is what happened to this exact bug. It was fixed once in srcfl/device-drivers#16 for srcfl/device-drivers#15, then promoting FTW's driver in srcfl/device-drivers#27 overwrote the catalog copy and took the fix with it. The flap you hit is that fix being reverted. The regression test that should have caught it ran the package target, which kept its copy, so nothing went red. srcfl/device-drivers#33 adds a test against the catalog driver, which is what the signed channel actually publishes, and verifies it against the unpatched baseline: three reads of 40288 over three polls before, one after. Your live-hardware evidence is the part that PR does not have. If the Pixii unit is still reachable, a note there once the new driver reaches it would close that gap. Closing in favour of srcfl/device-drivers#33. |
) Brings the two driver fixes from srcfl/ftw#703 and srcfl/ftw#702 to the repository that owns the drivers. pixii 2.1.0 → 2.1.1, solaredge_legacy 0.3.0 → 0.3.1. Closes srcfl/ftw#703, closes srcfl/ftw#702
What
Change
read_sf(addr)indrivers/pixii.luato remember addresseswhose first probe fails. Subsequent polls skip the
host.modbus_readcall for those addresses, using SF=0 (×1 scaling) directly — same
fallback semantics the current helper already provides, just without
the repeated failed read.
Why
On Pixii PowerShaper firmware, register 40288 (
meter_energy_sf,SunSpec Model 213 offset 32) returns Modbus exception 2 ("illegal data
address") — the SF register isn't populated by this firmware. Direct
raw Modbus TCP probe from the same host confirms:
The current
read_sfhandles the failure gracefully:But the Go host counts every failed
host.modbus_readtoward thedriver-poll error tally regardless of Lua-side
pcallhandling. Soon Pixii hardware the driver flaps
driver_poll: 1 of 36 modbus reads failedevery 5 s indefinitely, gets marked offline via the stale-telemetry watchdog every minute, watchdog writes setpoint=0 to the
Pixii every 5 s, and SoC / battery / meter data never reach the
planner. This is a regression vs
v0.120.9, where the same Pixiipolled cleanly on the same driver source.
Verified with all 26 unique
(addr, count)combinations fromgrep modbus_read drivers/pixii.lua: every one succeeds against thedevice except the single 40288 read. Instrumented
host.modbus_readinside the driver to log every failing address — only 40288 ever
fired.
Behaviour change (or lack thereof)
The
return 0semantics ofread_sfare unchanged. What changes:modbus_readcall entirely and return 0 immediately. Downstreamcode still uses SF=0 (×1 scaling) — bit-for-bit identical result.
On hardware where every SF read works, this patch is a no-op — the
cache fills with
truevalues and every read runs as before.Testing
Verified on Pixii PowerShaper firmware currently running an active
calibration cycle:
Before (v1.13.4 shipped driver):
After (this patch):
Status=0,ConsecutiveErrors=0, battery / meter / SoC data emit correctly.Import/export energy calculations still work —
meter_energy_sf=0means ×1 scaling, which matches what v0.120.9 has been doing on this
firmware for months without incident.
Related
solaredge_legacy.lua(MPPT block at 40123 onK-series firmware) — separate PR:
[#PR-solaredge-legacy-skip-unsupported-mppt]
modbus_readcalls regardless of Lua'spcall. Localized "cacheunsupported, skip subsequent reads" pattern fixes both.
Alternative
If a broader architectural approach is preferred, exposing a
host.modbus_read_optional(addr, n, fc)that doesn't count towardthe failure tally on nil returns would let drivers opt out declaratively.
Bigger surface change; the
read_sfpatch here contains the fix tothe one helper where "optional" SF registers enter the driver.