Was wondering, can I use kwp2000.py and tp20.py to query 56 Radio if I am sitting on the infotaiment 100kbps bus?
this is the example I tried this with
#!/usr/bin/env python3
from panda import Panda
from tp20 import TP20Transport
from kwp2000 import (
KWP2000Client,
SESSION_TYPE,
ECU_IDENTIFICATION_TYPE,
)
# ----------------------------------------------------
# Connect to Panda
# ----------------------------------------------------
p = Panda(port="COM11") # or Linux: "/dev/ttyUSB0"
p.set_safety_mode(Panda.SAFETY_ALLOUTPUT)
p.can_clear(0)
print("Connecting to Module 56 (Radio)…")
# ----------------------------------------------------
# Create TP2.0 transport for module 0x56
# ----------------------------------------------------
tp20 = TP20Transport(p, module=0x56, debug=True)
# ----------------------------------------------------
# Create KWP2000 client
# ----------------------------------------------------
kwp = KWP2000Client(tp20, debug=True)
# ----------------------------------------------------
# 1. Enter diagnostic session
# ----------------------------------------------------
print("Requesting diagnostic session…")
kwp.diagnostic_session_control(SESSION_TYPE.DIAGNOSTIC)
# ----------------------------------------------------
# 2. Read ECU identification (Part number)
# ----------------------------------------------------
ident = kwp.read_ecu_identifcation(ECU_IDENTIFICATION_TYPE.ECU_IDENT)
print("ECU Identification Raw:", ident.hex())
print("Part Number:", ident[:10].decode(errors="ignore"))
but for some reason I always get: tp20.MessageTimeoutError: Timed out waiting for message, even if I can see some CAN data
I also threw together this small CAN receiver
import threading
from panda import Panda
import binascii
import time
import sys
p = Panda(port="COM11") #on Linux: '/dev/ttyUSB0'
p.set_safety_mode(Panda.SAFETY_ALLOUTPUT)
p.can_clear(0)
print("Listening for CAN messages... (Ctrl+C to stop)")
try:
while True:
msgs = p.can_recv()
for address, data, bus, ts in msgs:
dlc = len(data)
data_hex = binascii.hexlify(data).decode().upper()
print(f"BUS {bus} ID 0x{address:03X} DLC {dlc} DATA {data_hex}")
time.sleep(0.01)
except KeyboardInterrupt:
print("Stopping")
finally:
p.close()
which does print data
BUS 0 ID 0x351 DLC 8 DATA 0100000000000080
BUS 0 ID 0x653 DLC 3 DATA 400040
BUS 0 ID 0x651 DLC 8 DATA C00462BF3453C100
BUS 0 ID 0x42B DLC 6 DATA 160100000000
BUS 0 ID 0x359 DLC 8 DATA FF01000000000000
BUS 0 ID 0x655 DLC 8 DATA 0008000008000058
BUS 0 ID 0x557 DLC 8 DATA 0000000008000048
BUS 0 ID 0x527 DLC 8 DATA 0700000000000000
BUS 0 ID 0x35B DLC 8 DATA 0F00000000000000
BUS 0 ID 0x65D DLC 8 DATA 8D000000000000C0
BUS 0 ID 0x436 DLC 8 DATA 0B01450100020000
BUS 0 ID 0x658 DLC 7 DATA 7000000E400000
so not sure whats going on, I thought that no matter on what bus I am, I can direcly comunicate with ECU (don't need gateway)
My ultimate goal is to make some kind of a sniffer with this kwp2000.py so I could see what OBDEleven is sending
Was wondering, can I use kwp2000.py and tp20.py to query 56 Radio if I am sitting on the infotaiment 100kbps bus?
this is the example I tried this with
but for some reason I always get: tp20.MessageTimeoutError: Timed out waiting for message, even if I can see some CAN data
I also threw together this small CAN receiver
which does print data
so not sure whats going on, I thought that no matter on what bus I am, I can direcly comunicate with ECU (don't need gateway)
My ultimate goal is to make some kind of a sniffer with this kwp2000.py so I could see what OBDEleven is sending