Skip to content

Recorded CAN Logs

farzad edited this page Oct 7, 2026 · 1 revision

Recorded CAN Logs

Most CAN data people want analysed is a recording, not a live car. Peykan reads recordings through python-can, summarises them in a form an AI model can reason about, extracts individual signals, and can replay them onto a bus so every live tool works on them.

Supported formats

Extension Format
.asc Vector ASCII
.blf Vector binary logging format
.trc PEAK PCAN-View trace
.log Linux candump
.csv python-can CSV
.db python-can SQLite
.mf4 ASAM MDF4 (needs pip install asammdf)

Signals are decoded with the configured DBC (PEYKAN_DBC_PATH) and the built-in J1939 catalog. For your own recordings, point PEYKAN_DBC_PATH at your vehicle's DBC.

The sample recording

sample is a bundled 30-second simulated drive (2563 frames): the car pulls away, and a misfire starts at 15 s. It's a good first test: an AI client should find the misfire codes and when they appeared.

From the CLI

peykan log-info sample                            # tables: IDs, signals, DTCs, gaps
peykan log-info drive.blf --json                  # the full analysis as JSON
peykan log-signal drive.blf ENGINE_SPEED          # one signal over time
peykan log-signal sample ENGINE_SPEED --message J1939:EEC1
peykan replay drive.blf --speed 2                 # put it back on the bus
peykan demo --log drive.blf                       # MCP server + dashboard on a looping replay
peykan record out.asc --simulate --seconds 30 --fault misfire --fault-at 15

The CLI reads any path you give it.

From an MCP client

list_can_logs, analyze_can_log(path), get_log_signal(path, signal_name, ...), replay_can_log(path, speed, loop), stop_log_replay(), or the analyze_log prompt.

Clients can only read files under PEYKAN_LOG_DIR (default: the server's working directory), plus sample. Paths are resolved, so ../ tricks and symlinks pointing outside are refused. list_can_logs looks at that directory and one level of subdirectories.

What the analysis contains

Field Content
frame_count, duration_s, error_frames, truncated Basics (logs are capped at 2 million frames)
ids Every arbitration ID: name (DBC message, J1939 PGN or OBD/UDS), count, rate and median period
signals Per signal and source message: min / max / mean / first / last and units, or value counts for enumerated signals. A name in two messages (e.g. ENGINE_SPEED in the DBC and in J1939 EEC1) is reported once per source
obd_dtcs Codes from OBD Mode 03 replies in the log, with first-seen time
j1939_dtcs Codes from DM1 messages (single-frame or multi-packet), with source address and first/last-seen time
timing_gaps Periodic IDs that went silent much longer than their normal period, e.g. 0x100 ENGINE_STATUS: 2.10 s gap at t=4.1 s (normally every 100 ms). Event-driven traffic (transport, OBD/UDS, the DBC diagnostic frames) is excluded

get_log_signal returns (t_s, value) points downsampled to max_points, with min/max/mean. When a signal occurs in several messages it picks the most frequent source and lists the others in other_sources; pass message to choose.

Replay

Frames are sent with their original spacing (scaled by speed) and stamped with the current time, so the live tools and the dashboard treat them as current traffic. Replaying transmits every frame in the log, so it counts as a write under the transmit policy: fine on the virtual bus, opt-in on real hardware.

Recording

peykan record writes whatever is on the configured bus to a file, with the format chosen by its extension. With --simulate it runs the simulator in the same process; --fault / --fault-at inject a fault partway through, which is how the bundled sample was made.

Clone this wiki locally