Skip to content

Instantly share code, notes, and snippets.

@surt91
Created October 20, 2023 16:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save surt91/63fca6e0fa4db120f181d31d884c622e to your computer and use it in GitHub Desktop.
Save surt91/63fca6e0fa4db120f181d31d884c622e to your computer and use it in GitHub Desktop.
scan_dids
import time
import udsoncan
from udsoncan.connections import IsoTPSocketConnection
from udsoncan.client import Client
from udsoncan.services import ReadDataByIdentifier
interface = "can0"
txid = 0x6C5
rxid = txid + 0x10
start = 256
end = 3500
conn = IsoTPSocketConnection(interface, rxid=rxid, txid=txid)
with Client(conn) as client:
for did in range(start, end):
try:
response = client.send_request(
udsoncan.Request(
service=ReadDataByIdentifier,
data=(did).to_bytes(2, byteorder='big')
)
)
if response.positive:
print(f"{did}:{len(response)}")
else:
print(f"{did}:0")
except Exception as e:
pass
# print(f"# DID {did}: Fehler: {e}")
time.sleep(0.1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment