Battery monitor: "not available" values decode as NAN

Each battery monitor field has a reserved "not available" raw value:
voltage 0x7FFF, aux 0xFFFF, current 0x3FFFFF, consumed Ah 0xFFFFF and
SOC 0x3FF. The parser decoded them as readings, so an unsynchronised
shunt reported SOC 102.3 % and an unavailable current came out as
-0.001 A after sign extension. They are now NAN in the C core.
Time-to-go stays an integer, with 0xFFFF named VICTRONBLE_TTG_NA. The
Arduino wrapper maps the new NANs to 0, as it already did for aux.

Adds a host test vector with every field not available, and notes in
the README that a battery monitor has now been decoded live on Zephyr
(ESP32-S3, Heltec WiFi LoRa 32 V3).
This commit is contained in:
scottp committed 2026-11-11 13:13:57 +11:00
1 parent 318e221170
commit 560ea24f60
9 files changed
+108 -31

No files matched your search

+14
View File
@@ -76,6 +76,19 @@ batmon = pad21(pack_bits([
(855, 10), # SOC, 0.1 %
]))
# Battery monitor before it has synchronised, with nothing on aux: every
# field carries Victron's "not available" value.
batmon_na = pad21(pack_bits([
(0xFFFF, 16), # TTG n/a
(0x7FFF, 16), # voltage n/a
(0x0000, 16), # no alarms
(0xFFFF, 16), # aux n/a
(0, 2), # aux mode = aux voltage
(0x3FFFFF, 22), # current n/a
(0xFFFFF, 20), # consumed n/a
(0x3FF, 10), # SOC n/a
]))
# Inverter: inverting, 25.86 V, -12.34 A, -230 W, overload alarm.
inverter = pad21(bytes([9, 0]) + le16(2586) + le16(-1234 & 0xFFFF) +
((-230) & 0xFFFFFF).to_bytes(3, "little") + bytes([0x08]))
@@ -97,6 +110,7 @@ accharger = pad21(pack_bits([
VECTORS = [
("solar", frame(0x01, 0xA060, 0x00, 0x1234, solar)),
("batmon", frame(0x02, 0xA389, 0x00, 0xBEEF, batmon)),
("batmon_na", frame(0x02, 0xA389, 0x00, 0xBEF0, batmon_na)),
("inverter", frame(0x03, 0xA2FA, 0x00, 0x0001, inverter)),
("dcdc", frame(0x04, 0xA3C0, 0x00, 0xFFFF, dcdc)),
("accharger", frame(0x08, 0xA339, 0x00, 0x00C8, accharger)),