# 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_mosfet_temp_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) + (0.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_mosfet_temp": dbc_4_mosfet_temp_physical(data),
}
Verify Pylontech-protocol 0x356 live pack values broadcast by JK Inverter BMS
JK PB-series Inverter BMS hardware communicates with Growatt, Deye, Luxpower and Victron GX controllers via standard Pylontech/SMA 500 kbps CAN messages including 0x356 status frames.
In Intel little-endian byte order, bytes 00 14 represent 0x1400 (5120 → 51.20 V), 2C 01 gives +300 (+30.0 A charge) while D4 FE flips to signed −300 (−30.0 A discharge), followed by 0x4E (78% SOC) and 0x19 (25 °C).
Formulas
Pack V = (0x14 << 8 | 0x00) × 0.01 = 5,120 × 0.01 = 51.20 V
Signed A = 0x012C (+300 → +30.0 A) vs. 0xFED4 (−300 → −30.0 A)
SOC byte = 0x4E (78%); Temp byte = 0x19 (25 °C)
Worked example
Frame 00 14 2C 01 4E 19 00 00 decodes in Intel LE order to 51.2 V, +30 A, 78% SOC and 25 °C alongside C99 bitfield extractors; switching to 00 14 D4 FE 4E 19 00 00 yields −30 A discharge.
Frequently asked questions
How do I check current sign polarity between JK BMS and my hybrid inverter?
Observe raw bytes 2–3 while charging with a known AC source—positive signed values (+30 A) indicate charging and two’s-complement values (0xFED4 = −30 A) indicate discharge.
What baud rate does JK Inverter BMS use for Victron/Pylontech CAN?
Inverter closed-loop BMS ports run 500 kbps standard 11-bit CAN with a 120 Ω termination resistor enabled at each end of the bus.
Do I put a crossover Ethernet cable between JK BMS and every hybrid inverter?
Always inspect the JK RJ45 CAN pinout (often Pins 4 CAN-H / 5 CAN-L) against your inverter’s BMS port pinout, as Victron Type-A uses Pins 7–8 while Pylontech/Deye use Pins 4–5.