Architecture¶
CANExplorer has three layers:
| Layer | Package | Depends on Qt |
|---|---|---|
| Core: sources, sessions, storage, decoding, protocols, diagnostics | can_explorer/core |
no |
| Scripting: simulation nodes and their runtime | can_explorer/scripting |
no |
| GUI adapters: models and controllers exposed to QML | can_explorer/gui |
yes |
| User interface | can_explorer/gui/qt (QML) |
yes |
The core is plain asyncio and is tested without Qt. Qt and asyncio share one event loop through
qasync (can_explorer/__main__.py), so coroutines, timers and Qt
signals all run on the GUI thread.
Receive pipeline¶
flowchart LR
bus[python-can Bus] -->|notifier thread| bridge[ThreadBridge]
file[Log file reader thread] --> bridge
bridge -->|batches| session[BusSession]
session --> trace[TraceBuffer]
session --> stats[IdStatistics / BusStatistics]
session --> signals[SignalTracker]
session --> recorder[Recorder]
session --> listeners[Message listeners: ISO-TP / LIN TP clients, simulation, panels]
trace -->|every 33 ms| models[Trace and overview models] --> qml[QML views]
- Sources (
core/sources.py):LiveSourcereads a python-can bus in python-can's notifier thread,FileSourcereads a log file in a worker thread. Both hand frames to the event loop through aThreadBridge, which wakes the loop once per batch instead of once per frame. - BusSession (
core/session.py) consumes the batches. For each frame it runs the protocol decoder (stateful, hence in arrival order), appends it to the boundedTraceBuffer, updates the per-identifier and bus statistics and the tracked signals, records it and calls the message listeners. After each batch it yields to the event loop so the GUI stays responsive under sustained traffic. It also transmits (single, periodic, hardware timed) and records. - Decoding (
core/decoding.py): the protocol decoder describes every frame on arrival; signal databases are stateless, so frames are only decoded with them when displayed, and the result is cached in the frame. -
GUI adapters (
gui/connection_manager.py,gui/models.py): aCanConnectionper connection drains the new frames from the session on a timer (33 ms by default) and appends them to the Qt models in one batch; the overview only refreshes the rows that changed. -
Garbage collection (
core/gc_control.py): while a session is open, Python's automatic full collections are suspended. A full collection walks every frame of every trace and stops all threads for 35 to 150 ms, long enough for the kernel's socket buffer (a few hundred frames) to overflow. Frames are freed by reference counting, so nothing builds up;CaptureGcruns the full collection itself when all buses together are below 500 frames/s, at most once a minute, or after 30 minutes regardless. Python 3.14's incremental collector scans old objects a slice at a time and ignores the generation 2 threshold, so thereCaptureGcstays inactive. - Columnar trace (
core/trace_columns.py, the compact trace preference, experimental):ColumnarTraceStorehas the interface ofTraceStorebut keeps the frames in memory as numpy columns (timestamp, identifier, flags, DLC, length, channel, data, protocol text). A full collection then no longer walks the trace, whatever its length, and a frame takes about 40 bytes instead of about 320. Appended frames are staged as objects and written to the columns in blocks of 1024 (or at the next read); reads turn them back intoFrameobjects, cached per page of 256 so a frame on screen keeps its identity and its decoded-signal cache.matching_indicesfilters the columns, and the records on disk, vectorised;TraceStorehas the same method as a plain loop, and the trace model uses it for both. The temporary files have the same format in both stores. The multi-bus view keepsTraceStore, since its frames carry the name of their connection. On Python 3.14, whereCaptureGcis inactive, this keeps the longest pause below 4 ms instead of 20 to 70 ms (measurements).
tools/benchmark.py measures the pipeline: about 300 000 frames per second with J1939 and DBC decoding on a desktop
computer. tools/benchmark_socketcan.py measures the whole path through SocketCAN: on a laptop (Intel Core Ultra 5
226V) no frames are lost up to 20 000 frames/s, more than two fully loaded 1 Mbit/s buses
(Building and testing).
Modules¶
| Module | Purpose |
|---|---|
core/frames.py |
Frame, hex parsing and formatting |
core/filters.py |
Display filter syntax |
core/store.py |
Trace ring buffer and per-identifier statistics |
core/busstats.py |
Frame rates and bus load |
core/signals.py |
Time series of tracked signals and bit fields |
core/database_io.py, core/dbf.py |
Loading, saving and converting signal databases; BUSMASTER DBF |
core/database_editor.py, core/ldf_editor.py, core/ldf_writer.py |
Editing CAN databases and LDF files; writing LDF files |
core/decoding.py, core/ldf.py |
Signal decoding with cantools databases and LDF files |
core/protocols/ |
Passive ISO-TP, J1939 and CANopen decoders |
core/lin.py, core/lin_tp.py, core/lin_schedule.py |
LIN frames and decoder, LIN transport client, LIN master |
core/isotp_client.py, core/uds.py |
Active ISO-TP client and UDS client and decoder |
core/flashing.py |
Intel HEX, S-record and binary images; UDS download sequence |
core/uds_scan.py |
Interactive UDS discovery: service, DID, subfunction and routine scans and a one-byte sweep over a UDS transport, with the answers classified |
core/uds_fuzz.py |
UDS mutation fuzzing: mutated requests from seeds or random ones, with a periodic liveness check that detects the ECU hanging or crashing |
core/can_command.py |
Request/response over a CAN session for command protocols (XCP, CCP) |
core/xcp.py, core/ccp.py |
XCP and CCP masters (memory access, seed & key, pages, checksum, DAQ; XCP also static DAQ, STIM and programming); core/ccp.py also its simulated slave |
core/xcp_flash.py |
Flash programming over XCP: the erase, program, verify and reset sequence for an image |
core/xcp_protocol.py, core/xcp_slave.py, core/xcp_ethernet.py |
XCP packet codes and checksums, the simulated XCP slave, XCP on UDP/TCP |
core/a2l.py, core/calibration.py, core/calibration_session.py |
A2L reader (variables, layouts, conversions, IF_DATA), reading/writing values by name and datasets (JSON, DCM), the session of the MCP xcp_* tools |
core/a2l.py |
A minimal A2L (ASAM MCD-2 MC) reader: measurements and scalar characteristics with address, data type and linear conversion |
core/someip.py |
SOME/IP and SOME/IP-SD parsing, and a UDP monitor tracking discovered services |
core/someip_serialization.py, core/someip_fibex.py |
SOME/IP payload serialization (type model and deserializer) and a FIBEX reader that builds it |
core/doip.py |
Diagnostics over IP (ISO 13400-2): vehicle discovery, entity status and power mode over UDP; the tester's TCP connection with routing activation and alive checks; the UDS transport per target address; the simulated DoIP entity |
core/j1939_tools.py |
J1939 NAME, DM1/DM2, transport reassembly, network tracking and sending with BAM or RTS/CTS |
core/canopen_tools.py |
EDS/DCF object dictionaries, SDO client, NMT, PDO mappings, network tracking, simulated node |
core/physical_io.py |
Digital lines and analogue inputs: aio_usb (pyusb) and simulated devices, polled on a worker thread |
core/gvret.py |
GvretBus, the python-can interface for GVRET devices (SavvyCAN protocol) |
core/panda_usb.py |
PandaBus, the python-can interface for comma.ai pandas on USB (CAN and CAN FD) |
core/lin_adapter.py |
LinAdapterBus, the base of the LIN adapter interfaces: master/slave, sllin-convention frames |
core/plin.py, core/kvaser_lin.py, core/vector_lin.py |
The LIN adapter interfaces for PEAK (PLIN-API), Kvaser (LINlib) and Vector (XL Driver Library) |
core/panda_udp.py |
PandaUdpBus, the receive-only python-can interface for the WiFi UDP stream of a comma.ai panda |
core/j2534.py, core/j2534_driver.py, core/j2534_bridge.py |
J2534Bus, the python-can interface for J2534 pass-thru drivers: registry lookup and DLL architecture check; the ctypes driver calls (standard library only); the 32-bit bridge process that runs them for 32-bit drivers, over JSON lines on stdin/stdout |
core/elm327.py |
Elm327Bus, the python-can interface for ELM327 and OBDLink OBD adapters (text commands, monitoring on a worker thread) |
core/ethercat.py |
EtherCAT master for CoE: SOEM (pysoem) and simulated backends on a worker thread, states, SDO, SDO information, PDO assignment |
core/mqtt.py, gui/mqtt.py |
MQTT bridge of a bus (aiomqtt on a thread of its own): signals, frames and status out, allow-listed send requests in; the connection's MQTT controller |
core/compare.py |
Comparing two recordings |
core/gateway.py |
Bus gateway: forwarding rules between sessions, with filtering, identifier rewriting, rate limiting and an echo guard |
core/reverse/reactions.py |
Reverse engineering: baseline-vs-action diffing (Capture reaction) |
core/reverse/timeline.py |
Reverse engineering: the frames of one identifier over time, for the Bits-tab replay scrubber |
core/reverse/ |
Reverse engineering: bit fields (fields.py), bit and byte statistics with the notch (bitstats.py), checksum detection (checksums.py), the automatic analysis of fields, their kinds and multiplexers (analysis.py), correlation with reference signals (reference.py) and OBD-II polling (obd.py), grouping fields that carry the same signal (related.py), event markers (markers.py), synthetic traffic with known signals and scoring of found fields (synthetic.py) |
core/bushealth.py |
Error frame decoding, error states and the bus health history |
core/updates.py, gui/updates.py |
Finding, downloading, verifying and installing new releases from GitHub |
core/remote.py |
RemoteBus, the python-can interface for buses shared by can-server |
core/diagnostic_description.py, core/odx.py |
ECU diagnostic descriptions: CANdelaStudio CDD; ASAM ODX and packaged ODX (PDX) |
core/trace_store.py |
Trace frames in memory and in temporary files on disk, by absolute index |
core/trace_columns.py |
The same trace store with the frames in memory as numpy columns (the compact preference) |
core/conditions.py, core/recording.py |
Conditions on frames; split and triggered recordings |
core/simulation.py |
Simulated UDS ECU and LIN slaves (tests, demos) |
scripting/ |
Simulation node API and runtime |
gui/connection_manager.py |
Connections, preferences and channel detection for QML |
gui/models.py |
Trace (a paged view of the trace store) and overview table models |
gui/trace_tools.py, gui/workspace.py |
Trace search and bookmarks; workspace files |
gui/diagnostics.py, gui/simulation.py |
Diagnostics and simulation controllers, panel bridge |
gui/flashing.py, gui/j1939.py, gui/canopen.py, gui/uds_scan.py, gui/xcp.py |
Flashing, J1939, CANopen, UDS discovery and XCP/CCP measurement & calibration controllers of a connection |
gui/database_editor.py, gui/compare.py, gui/multibus.py, gui/ethercat.py, gui/physical_io.py, gui/doip.py, gui/gateway.py |
Database editor, recording comparison, multi-bus trace, EtherCAT, Physical I/O, DoIP and bus gateway tools (the DoIP tool reuses the diagnostics and flashing controllers with its own transport) |
gui/bushealth.py |
Bus health page of a connection |
gui/reverse.py, gui/reverse_tools.py |
Reverse engineering page of a connection; its analysis, reference and marker tools (run in a worker thread) |
gui/translations.py |
Translations from Qt Linguist files |
gui/file_picker.py, core/file_dialog_filters.py |
File open/save dialogs of the QML views (the FileChooser QML type, shown with QtWidgets' QFileDialog); the default suffix of a name filter |
gui/plot_view.py, gui/signal_plot.py |
Time range, cursors and charts of the signal plots; plot item (QQuickPaintedItem) |
gui/app_state.py |
Persistent settings (QSettings) |
gui/qt/CanExplorer/ |
QML views, dialogs and dashboard components; Theme.qml holds the colours of the themes, GlassPanel.qml the frosted glass of dialogs, menus and popups |
gui/qt/CanExplorerStyle/ |
Qt Quick Controls style drawing buttons, inputs, dialogs, menus etc. with the theme colours (Fusion for the rest) |
build_info.py |
The running build: version, commit, build date and packaging backend |
core/channel_detection.py |
Channel detection of every python-can backend, with the outcome of each (found, none, unavailable, unsupported, error, timeout) and a retry alone of those that failed |
core/interface_check.py |
canexplorer --check-interfaces: loads CANExplorer's python-can interfaces, gs_usb, CANalyst-II and libusb, and reports each; run on every release bundle |
core/usb_backend.py |
The libusb library for pyusb (from libusb-package, bundled in the installers), also for gs_usb and CANalyst-II, which look it up themselves |
core/e2e_check.py |
Live AUTOSAR E2E checks (profiles 2, 5, 22) of signal PDUs, configured from the E2E protections of an ARXML |
core/keystore.py |
The security manager's encrypted key store (scrypt and AES-256-GCM): SecOC keys, TLS certificates, IPsec/MACsec associations |
core/secoc.py, core/secoc_check.py |
SecOC primitives (CMAC/AES); live checks and securing of the secured PDUs of an ARXML, with freshness value managers |
core/tls.py |
TLS client contexts for DoIP from key store entries |
core/packet_decryption.py |
Decrypting IPsec ESP and MACsec frames of an Ethernet capture |
gui/security.py |
The Security Manager: the key store and the SecOC verifiers, packet decryptor and TLS contexts handed to the other tools |
sys/system_report.py |
The system report for bug reports (versions, Qt setup, channel detection, crash report) |
sys/config.py, sys/environment.py, sys/crash_log.py |
Application settings; clean-up of snap environments; crash reports (faulthandler writing to a per-user file, kept when the run crashed) |
can_server/ |
can-server: shares local CAN interfaces over WebSocket |
can_explorer/mcp/ |
can-mcp: exposes a bus to an agent over the Model Context Protocol (service.py the logic, server.py the MCP tools) |