# Pure Python 3 CAN decoder for a 8-byte payload.
FRAME_LEN = 8
def dbc_1_pack_voltage_physical(data: bytes) -> float:
if len(data) < 8:
raise ValueError("Expected at least 8 payload bytes")
raw = (int.from_bytes(data[:8], "little") >> 0) & 0xFFFF
return raw * (0.01) + (0.0)
def dbc_2_pack_current_physical(data: bytes) -> float:
if len(data) < 8:
raise ValueError("Expected at least 8 payload bytes")
raw = (int.from_bytes(data[:8], "little") >> 16) & 0xFFFF
if raw & (1 << 15):
raw -= 1 << 16
return raw * (0.1) + (0.0)
def dbc_3_state_of_charge_physical(data: bytes) -> float:
if len(data) < 8:
raise ValueError("Expected at least 8 payload bytes")
raw = (int.from_bytes(data[:8], "little") >> 32) & 0xFF
return raw * (1.0) + (0.0)
def dbc_4_module_temperature_physical(data: bytes) -> float:
if len(data) < 8:
raise ValueError("Expected at least 8 payload bytes")
raw = (int.from_bytes(data[:8], "little") >> 40) & 0xFF
return raw * (1.0) + (-40.0)
def decode_frame(data: bytes) -> dict[str, float]:
return {
"dbc_1_pack_voltage": dbc_1_pack_voltage_physical(data),
"dbc_2_pack_current": dbc_2_pack_current_physical(data),
"dbc_3_state_of_charge": dbc_3_state_of_charge_physical(data),
"dbc_4_module_temperature": dbc_4_module_temperature_physical(data),
}
Inspect 16-bit signed current and scaling in low-voltage ESS BMS CAN frames
Low-voltage 48 V rack batteries and solar inverter BMS buses (Pylontech, Victron Venus, JK/Seplos adapters) typically transmit telemetry at 500 kbps using standard 11-bit frames with Intel little-endian multi-byte words.
Bytes 0–1 (A0 14 → 0x14A0 = 5,280 → 52.80 V) and signed bytes 2–3 (FA 00 → +250 → +25.0 A; or FE 3E / 3E FE → −45.0 A when discharging) let you verify polarity before enabling closed-loop charge limits on your inverter.
Formulas
Intel 16-bit LE word = byte[n] | (byte[n+1] << 8)
Pack voltage (V) = 0x14A0 (5,280) × 0.01 = 52.80 V
Signed two’s-complement current = 0xFE3E (−450) × 0.1 = −45.0 A
Worked example
Payload A0 14 FA 00 55 41 00 00 decodes cleanly to 52.8 V, +25 A charging current, 85% SOC and 25 °C temperature (65 − 40 offset), generating ready-to-compile C99 unpack functions.
Frequently asked questions
Why does byte 0 + byte 1 (A0 14) become 0x14A0 instead of 0xA014?
Intel little-endian ordering places the least significant byte first in the CAN frame payload, so byte 1 forms the upper byte of the 16-bit word.
What happens if inverter BMS telemetry expects a 0.1 V scale instead of 0.01 V?
Update the Scale field directly on that row to verify whether the manufacturer’s DBC frame scales voltage by 0.01 (5280 = 52.80 V) or 0.1 (528 = 52.8 V).
How do I switch between Intel and Motorola byte order in the generated C99 code?
Toggle the Byte order dropdown on any signal row; the decoder updates the visual bit map and regenerates the DBC_BIT shift masks automatically.