A Python library for automotive diagnostics implementing legacy protocol stacks commonly used on VAG and BMW platforms.
| Protocol | Bus | Hardware | Use Case |
|---|---|---|---|
| KWP2000 TP20 | CAN | J2534 adapter | VAG vehicles (~2004–2010, pre-UDS) |
| KWP2000 CAN | CAN | J2534 adapter | BMW vehicles (ISO-TP with address byte) |
| KWP2000 CAN | CAN | K-DCAN cable | BMW vehicles via USB adapter |
| KWP2000 | K-Line | Serial/USB | BMW vehicles over K-Line |
| DS2 | K-Line | Serial/USB | BMW vehicles (pre-KWP2000 era) |
pip install kwp2000-canFor serial/K-Line communication, also install pyserial:
pip install pyserialfrom kwp2000_can.protocols.kwp2000.can import KWP2000_TP20_J2534
with KWP2000_TP20_J2534() as client:
data = client.readDataByLocalIdentifier(local_identifier=0x01)
print(data)See examples.md for complete usage examples for all protocols.
- Clean layering — Compose transports and clients; context-manager friendly
- KWP2000 services — Sessions, Read/Write Memory, ECU Identification, Routine Control, Timing Parameters, and more
- DS2 services — Ident, Read/Write Memory, Activate/Deactivate tests
- J2534 Pass-Thru — Auto-detects DLL when possible
- Serial transports — pyserial-based with baudrate scanning
| Variant | Baudrate | Checksum |
|---|---|---|
| KWP2000 | 10400 baud | Additive |
| KWP2000-STAR | 9600 baud | XOR |
| BMW-FAST | 115200 baud | Additive |
python -m pytest tests/- Python 3.7+
python-can>=4.0.0- J2534-compatible hardware (for CAN protocols)
- pyserial (for K-Line protocols)
MIT License — see LICENSE for details.