GKBus
Automotive diagnostic protocols library powering the GKFlasher
1from gkbus.hardware import CanHardware, KLineHardware
2from gkbus.protocol import kwp2000
3from gkbus.transport import Kwp2000OverKLineTransport
4
5print('available KLineHardware ports')
6ports = KLineHardware.available_ports()
7for port in ports:
8 print(f' {port.description()}')
9
10print('available CanHardware ports')
11can_ports = CanHardware.available_ports()
12for port in can_ports:
13 print(f' {port.description()}')
14
15print('creating hardware')
16hardware = KLineHardware(ports[0].port)
17transport = Kwp2000OverKLineTransport(hardware, tx_id=0x11, rx_id=0xf1)
18kwp = kwp2000.Kwp2000Protocol(transport)
19
20print('fast init')
21init_success = kwp.init(kwp2000.commands.StartCommunication())
22print('fast init : {}'.format(init_success))
23
24print('executing ReadEcuIdentification: 0x8c - bootloader version')
25response = kwp.execute(kwp2000.commands.ReadEcuIdentification(0x8c))
26print(response)
Supported protocols
Kwp2000 (ISO14230) - over CAN and K-Line
CCP (Can Calibration Protocol) - over CAN
Supported hardware
Physical layer |
Supported hardware |
|---|---|
K-Line (ISO 9141-2/14230-1) |
Basically any native serial port. Genuine FTDI adapters work best, knockoff FTDI and CH340 are also tested |
CAN bus |
On Linux, anything that shows up as a native CAN network interface. Kernel ISO-TP module is used when available. On Windows, while everything supported by python-can should work, it was not tested. |
Installing
GKBus is available on PyPi:
`console
$ python -m pip install gkbus
`
API Reference available on [Read the Docs](https://gkbus.readthedocs.io)
Overview
GKBus operates on three layers: hardware, transport, protocol. […]