python-can
import can, cantools
from cantools.j1939 import pgn_from_frame_id
CHANNEL = "1f72d84a-usb.local@1"
db = cantools.database.load_file("j1939.dbc", strict=False)
eec1 = db.get_message_by_name("EEC1")
EEC1_PGN = pgn_from_frame_id(eec1.frame_id)
with can.Bus(interface="cansub", channel=CHANNEL, bitrate=250_000, data_bitrate=1_000_000) as bus:
for msg in bus:
if pgn_from_frame_id(msg.arbitration_id) == EEC1_PGN:
print(f"{msg.timestamp:.3f} EngineSpeed = {eec1.decode(msg.data)['EngineSpeed']} rpm")
Python is a popular programming language. Our python-can-cansub package registers the CANsub as a python-can interface, making it compatible with all python-can tools/workflows.
Get started via the GitHub link below - and see this section for extra demos:
Configure - configure the device via python-can / REST
Demos - simple demo examples / mini applications
Note
For guidance on using Python e.g. for OBD2, J1939 or NMEA 2000 see the protocols section
Note
We strongly recommend seeing our AI assistants guide when building Python scripts/apps
Installation & get started (GitHub)
Download the GitHub repository and follow the README documentation:
Note
Each python-can-cansub release supports one API version. The API version for each CANsub firmware release is listed in the CANsub Docs changelog