Protocols

class obdii.protocols.ProtocolCAN[source]

Bases: ProtocolBase

Supported Protocols: - [0x06] ISO 15765-4 CAN (11 bit ID, 500 Kbaud) - [0x07] ISO 15765-4 CAN (29 bit ID, 500 Kbaud) - [0x08] ISO 15765-4 CAN (11 bit ID, 250 Kbaud) - [0x09] ISO 15765-4 CAN (29 bit ID, 250 Kbaud) - [0x0A] SAE J1939 CAN (29 bit ID, 250 Kbaud) - [0x0B] USER1 CAN (11 bit ID, 125 Kbaud) - [0x0C] USER2 CAN (11 bit ID, 50 Kbaud)

static to_lines(raw: bytes) List[bytes][source]
static to_frames(lines: List[bytes], header_len: int) List[CANFrame][source]

Parse a list of raw ELM327 lines into CANFrame objects.

Frame anatomy and examples

Single Frame (SF) - complete message in one line

7E8 04 41 0C 41 C2
|   |  |
|   |  +-- payload: mode (41) + PID (0C) + data (41 C2)
|   +-- PCI: high nibble 0x0 = SF, low nibble 0x4 = DLC (4 bytes)
+-- ECU address (11-bit)

First Frame (FF) - first frame of a multi-frame message

7E8 10 14 49 02 01 57 50 30
|   |  |  |
|   |  |  +-- payload start: mode (49) + PID (02) + data (57 50 30)
|   |  +-- DLC low byte: 0x14 = 20 -> DLC(20 bytes)
|   +-- PCI: high nibble 0x1 = FF, low nibble 0x0 = DLC high bits
+-- ECU address (11-bit)

Consecutive Frame (CF) - continuation of a multi-frame message

7E8 21 5A 5A 5A 39 39 5A 54
|   |  |
|   |  +-- payload continuation (no mode, no PID, only data)
|   +-- PCI: high nibble 0x2 = CF, low nibble 0x1 = SN
+-- ECU address (11-bit)
static to_message(frames: List[CANFrame], command: Command) List[int] | None[source]
parse_response(response_base: ResponseBase) Response[source]
class obdii.protocols.ProtocolJ1850[source]

Bases: ProtocolBase

Supported Protocols: - [0x01] SAE J1850 PWM (41.6 Kbaud) - [0x02] SAE J1850 VPW (10.4 Kbaud)

parse_response(response_base: ResponseBase) Response[source]
class obdii.protocols.ProtocolKWP2000[source]

Bases: ProtocolBase

Supported Protocols: - [0x03] ISO 9141-2 (5 baud init, 10.4 Kbaud) - [0x04] ISO 14230-4 KWP (5 baud init, 10.4 Kbaud) - [0x05] ISO 14230-4 KWP (fast init, 10.4 Kbaud)

parse_response(response_base: ResponseBase) Response[source]