Finding one signal by hand means logging, flipping a switch, staring at hex and guessing. Researchers have automated the statistical part since at least 2018, and LLM coding agents can now run those scripts for you. This guide builds a small pipeline, runs it on a log where the right answer is known, and shows what it finds, what it misses, and what an LLM should and should not do in the loop.

If you have never found a signal manually, read building a DBC from reverse-engineered CAN logs first. The pipeline below automates those steps; it does not replace understanding them.

What the research already does

SystemPublishedIdea
Stone, Graham, MullinsAFIT dissertation 2018, arXiv 2019Group bits into signals by how often they change (the TANG metric)
READIEEE TIFS 2019Split the payload where the bit-flip rate drops from one bit to the next
LibreCANACM CCS 2019Match candidate signals against OBD-II data and smartphone sensors
CAN-DIEEE TVT 2021Four steps: boundaries, byte order, signedness, physical meaning. Outputs a DBC
CANMatchIEEE TVT 2021Reuse frame IDs and signals known from other vehicles
ByCANarXiv 2024Find byte-level boundaries first, then refine at bit level

CSS Electronics' guide to AI-assisted reverse engineering (updated June 2026) describes Claude Code skills that run a similar workflow with an LLM agent: a bit-activity survey, correlation against a reference signal, an exhaustive bit search scored by R², and a scale and offset fit. The vendor calls it an illustration rather than a polished tool, and gives no accuracy figures.

The common thread: every method that names a signal compares it with a reference whose meaning is known. Statistics can find boundaries without one; they cannot tell you that a field is vehicle speed.

The test log

To measure a pipeline you need a log where the answer is known. This guide uses a 300-second synthetic drive generated from a DBC:

MessageIDPeriodSignals
ESP_Speed0x1A020 msCRC, counter, VehicleSpeed at bit 16, 16 bits, Intel, 0.01 km/h
Wheel_Speeds0x1B020 msFour wheel speeds, 16 bits each, 0.01 km/h, slightly different from vehicle speed
Engine_Data0x2B020 msEngineSpeed at bit 7, 16 bits, Motorola, 0.25 rpm; coolant, throttle, counter
Body_Status0x3C0100 msDoor, brake pedal, outside temperature
OBD-II0x7DF / 0x7E8250 msAlternating requests and replies for PID 0D (speed) and 0C (rpm)

Engine speed follows a five-speed gearbox, so it is not a straight function of vehicle speed. Download make_synthetic_log.py, the truth DBC and the full pipeline, then run:

Terminal
python3 make_synthetic_log.py
python3 re_pipeline.py

The log is 50 400 lines in candump format, about 2.3 MB. The results below are from that log. A real vehicle adds noise, filtering and timing effects this log does not have, so treat these numbers as a best case.

Step 1: survey the bus

Load the log and summarise each CAN ID: how many frames, how often, and how often each byte changes. The OBD-II references are read from the request and reply pairs; each value is timed at its request, because the ECU answers some milliseconds later.

Python
import bisect
import statistics
from collections import defaultdict

OBD_IDS = (0x7DF, 0x7E8)


def load_candump(path):
    """{can_id: [(timestamp, data), ...]} from a candump -l log."""
    frames = defaultdict(list)
    with open(path) as log:
        for line in log:
            stamp, _, frame = line.split()
            can_id, data = frame.split("#")
            frames[int(can_id, 16)].append((float(stamp.strip("()")), bytes.fromhex(data)))
    return frames


def obd_reference(frames, pid):
    """Reference series [(request time, value)] from OBD-II PID 0x0D (km/h) or 0x0C (rpm) replies.

    The reply arrives some milliseconds after the request, so it is timed at the request.
    """
    formulas = {0x0D: lambda d: d[3], 0x0C: lambda d: (256 * d[3] + d[4]) / 4}
    requests = [t for t, d in frames[0x7DF] if d[1:3] == bytes([0x01, pid])]
    series = []
    for t, d in frames[0x7E8]:
        index = bisect.bisect_right(requests, t) - 1
        if d[1:3] == bytes([0x41, pid]) and index >= 0:
            series.append((requests[index], formulas[pid](d)))
    return series


def survey(frames):
    """One line per CAN ID: frames, period and how often each byte changes."""
    for can_id, items in sorted(frames.items()):
        if can_id in OBD_IDS:
            continue
        datas = [d for _, d in items]
        period_ms = (items[-1][0] - items[0][0]) / (len(items) - 1) * 1000
        rates = [sum(a[i] != b[i] for a, b in zip(datas, datas[1:])) / (len(datas) - 1) for i in range(8)]
        print(f"{can_id:03X}  {len(items):6} frames  {period_ms:5.1f} ms  byte change rate: "
              + " ".join(f"{r:.3f}" for r in rates))

Output of survey(frames):

Example
1A0   15000 frames   20.0 ms  byte change rate: 1.000 1.000 0.558 0.009 0.000 0.000 0.000 0.000
1B0   15000 frames   20.0 ms  byte change rate: 0.895 0.016 0.893 0.013 0.894 0.013 0.894 0.013
2B0   15000 frames   20.0 ms  byte change rate: 0.177 0.993 0.004 0.058 0.000 0.000 0.000 1.000
3C0    3000 frames  100.0 ms  byte change rate: 0.001 0.003 0.000 0.000 0.000 0.000 0.000 0.000

This table is already most of the story:

  • 1A0 bytes 0 and 1 change in every frame: a CRC and a counter, which the counters and CRC guide shows how to confirm. Bytes 2 and 3 change like the low and high byte of a 16-bit number.
  • 1B0 has four identical patterns: four 16-bit values that move together.
  • 2B0 byte 7 changes in every frame (a counter), and byte 1 nearly always: the low byte of a busy value whose high byte is byte 0. That is a hint of big-endian order.
  • 3C0 barely changes. Its signals will not follow speed or rpm.

Step 2: find the message and bytes

For each reference value, take the latest frame of each ID at that moment, read every 8- and 16-bit field at a byte boundary in both byte orders, and rank them by Spearman rank correlation. Rank correlation only asks whether the field goes up and down with the reference, so it works before you know the scale.

Python
def frames_at(items, times):
    """The latest frame at or before each reference time."""
    stamps = [t for t, _ in items]
    return [items[max(0, bisect.bisect_right(stamps, t) - 1)][1] for t in times]


def extract(data_int, start, length, big_endian, signed, width=64):
    """Raw value of a DBC-style field. data_int is the payload as one integer (little or big endian)."""
    if big_endian:  # Motorola: start is the most significant bit, numbered like Intel bits
        msb = (start // 8) * 8 + (7 - start % 8)
        raw = (data_int >> (width - msb - length)) & ((1 << length) - 1)
    else:
        raw = (data_int >> start) & ((1 << length) - 1)
    if signed and raw >> (length - 1):
        raw -= 1 << length
    return raw


def rank_messages(frames, reference):
    """Stage 1: which CAN ID and byte pair follows the reference? Spearman rank correlation."""
    times = [t for t, _ in reference]
    values = [v for _, v in reference]
    results = []
    for can_id, items in frames.items():
        if can_id in OBD_IDS:
            continue
        datas = frames_at(items, times)
        little = [int.from_bytes(d, "little") for d in datas]
        big = [int.from_bytes(d, "big") for d in datas]
        for byte in range(8):
            for size, big_endian in ((8, False), (16, False), (16, True)):
                if byte + size // 8 > 8:
                    continue
                start = byte * 8 + 7 if big_endian else byte * 8
                raw = [extract(x, start, size, big_endian, False) for x in (big if big_endian else little)]
                if len(set(raw)) > 2:
                    rho = statistics.correlation(raw, values, method="ranked")
                    results.append((round(abs(rho), 4), can_id, byte, size, "big" if big_endian else "little"))
    return sorted(results, reverse=True)

Step 3: search the exact bits

Then search one CAN ID exhaustively: every start bit, length from 2 to 16, byte order and sign, scored by R² of a straight-line fit. Two rules keep the search from returning nonsense:

  1. Both ends of the field must change. Bits that never change cannot be told apart from padding.
  2. The lowest bit must flip at least half as often as the busiest bit in the field. In a number, the least significant bit flips most. A field whose bottom end sits in a slow neighbouring signal fails this test. This is the same observation READ uses to find boundaries.

Among fields with the same R², the longest wins, so the low bits that carry fine resolution stay in.

Python
def flip_rates(items):
    """How often each Intel bit (0-63) changes between consecutive frames."""
    ints = [int.from_bytes(d, "little") for _, d in items]
    counts = [0] * 64
    for a, b in zip(ints, ints[1:]):
        changed = a ^ b
        for bit in range(64):
            counts[bit] += changed >> bit & 1
    return [c / (len(ints) - 1) for c in counts]


def field_bits(start, length, big_endian):
    """Intel bit numbers covered by a field, from LSB to MSB."""
    if not big_endian:
        return list(range(start, start + length))
    bits, bit = [], start
    for _ in range(length):  # Motorola: walk down from the MSB, jumping to the next byte at bit 0
        bits.append(bit)
        bit = bit - 1 if bit % 8 else bit + 15
    return bits[::-1]


def search_bits(items, reference, max_length=16):
    """Stage 2: every start bit, length, byte order and sign on one CAN ID, scored by R²."""
    times = [t for t, _ in reference]
    values = [v for _, v in reference]
    datas = frames_at(items, times)
    rates = flip_rates(items)
    little = [int.from_bytes(d, "little") for d in datas]
    big = [int.from_bytes(d, "big") for d in datas]
    results = []
    for big_endian in (False, True):
        for start in range(64):
            for length in range(2, max_length + 1):
                bits = field_bits(start, length, big_endian)
                if max(bits) > 63 or not rates[bits[0]] or not rates[bits[-1]]:
                    continue  # both ends must change at least once
                if rates[bits[0]] < 0.5 * max(rates[b] for b in bits):
                    continue  # in a number, the lowest bit flips most often
                for signed in (False, True):
                    raw = [extract(x, start, length, big_endian, signed) for x in (big if big_endian else little)]
                    if len(set(raw)) > 2:
                        r2 = statistics.correlation(raw, values) ** 2
                        results.append((round(r2, 4), length, start, big_endian, signed))
    results.sort(key=lambda r: (r[0], r[1]), reverse=True)  # best fit, then the longest field
    return results


def pad_to_byte(items, start, length, big_endian):
    """Grow the field over unused top bits up to a byte boundary. A guess: the data cannot prove them."""
    rates = flip_rates(items)
    if big_endian:
        while start % 8 != 7 and not rates[start + 1]:
            start, length = start + 1, length + 1
    else:
        while (start + length) % 8 and not rates[start + length]:
            length += 1
    return start, length

pad_to_byte exists because the data cannot prove a signal's top bits. Vehicle speed in this log never exceeds 92 km/h, which is 9 200 raw, so bits 14 and 15 of the field are always 0. Extending to the byte boundary is a guess, and it is labelled as one.

Step 4: scale, offset and a check on unseen data

Fit the factor and offset by least squares, round the factor to a value manufacturers commonly use if that changes it by less than 3 %, and score the decoded signal on the last 40 % of the log, which the search never saw:

Python
NICE_FACTORS = sorted({m * 10.0 ** e for m in (1, 2, 2.5, 4, 5) for e in range(-4, 3)} | {2.0 ** -n for n in range(1, 9)})


def fit_scale(items, reference, start, length, big_endian, signed):
    """Factor and offset by least squares, factor rounded to a value OEMs commonly use."""
    datas = frames_at(items, [t for t, _ in reference])
    raw = [extract(int.from_bytes(d, "big" if big_endian else "little"), start, length, big_endian, signed)
           for d in datas]
    values = [v for _, v in reference]
    slope, intercept = statistics.linear_regression(raw, values)
    nice = min(NICE_FACTORS, key=lambda f: abs(f / abs(slope) - 1))
    factor = nice if abs(nice / abs(slope) - 1) < 0.03 else slope
    factor = factor if slope > 0 else -factor
    offset = round(statistics.fmean(v - factor * r for r, v in zip(raw, values)), 1) + 0.0
    return factor, offset, slope, intercept


def score(items, reference, start, length, big_endian, signed, factor, offset):
    """R² and RMS error of the decoded signal against the reference."""
    datas = frames_at(items, [t for t, _ in reference])
    decoded = [factor * extract(int.from_bytes(d, "big" if big_endian else "little"), start, length,
                                big_endian, signed) + offset for d in datas]
    values = [v for _, v in reference]
    rms = statistics.fmean((a - b) ** 2 for a, b in zip(decoded, values)) ** 0.5
    return statistics.correlation(decoded, values) ** 2, rms


def dbc_line(name, start, length, big_endian, signed, factor, offset, unit):
    order, sign = ("0" if big_endian else "1"), ("-" if signed else "+")
    return f' SG_ {name} : {start}|{length}@{order}{sign} ({factor:g},{offset:g}) [0|0] "{unit}" Vector__XXX'

And the main loop:

Python
frames = load_candump("synthetic.log")
survey(frames)

for pid, name, unit in ((0x0D, "VehicleSpeed", "km/h"), (0x0C, "EngineSpeed", "rpm")):
    reference = obd_reference(frames, pid)
    split = int(len(reference) * 0.6)
    train, test = reference[:split], reference[split:]  # fit on the first 60 %, check on the rest

    print(f"\n{name}: fields that follow the reference")
    ranked = rank_messages(frames, train)
    for rho, can_id, byte, size, order in ranked[:5]:
        print(f"  {can_id:03X}  byte {byte}  {size:2}-bit {order:<6}  rho {rho}")

    can_id = ranked[0][1]
    r2, length, start, big_endian, signed = search_bits(frames[can_id], train)[0]
    start, length = pad_to_byte(frames[can_id], start, length, big_endian)
    factor, offset, *_ = fit_scale(frames[can_id], train, start, length, big_endian, signed)
    r2, rms = score(frames[can_id], test, start, length, big_endian, signed, factor, offset)
    print(f"  0x{can_id:03X}: held-out R² {r2:.4f}, RMS error {rms:.2f} {unit}")
    print(dbc_line(name, start, length, big_endian, signed, factor, offset, unit))

Results

The output after the survey:

Example
VehicleSpeed: fields that follow the reference
  1A0  byte 2  16-bit little  rho 0.9987
  1B0  byte 2  16-bit little  rho 0.9983
  1B0  byte 6  16-bit little  rho 0.9982
  1B0  byte 4  16-bit little  rho 0.9982
  1B0  byte 0  16-bit little  rho 0.9982
  0x1A0: held-out R² 0.9998, RMS error 0.25 km/h
 SG_ VehicleSpeed : 16|16@1+ (0.01,0) [0|0] "km/h" Vector__XXX

EngineSpeed: fields that follow the reference
  2B0  byte 0  16-bit big     rho 0.9846
  2B0  byte 0   8-bit little  rho 0.9749
  1A0  byte 2  16-bit little  rho 0.9066
  1B0  byte 6  16-bit little  rho 0.9064
  1B0  byte 4  16-bit little  rho 0.9064
  0x2B0: held-out R² 0.9998, RMS error 12.17 rpm
 SG_ EngineSpeed : 7|16@0+ (0.25,2) [0|0] "rpm" Vector__XXX

Compared with the DBC that generated the log:

SignalTruthFoundDifference
VehicleSpeed0x1A0, 16\16@1+, factor 0.01, offset 00x1A0, 16\16@1+, factor 0.01, offset 0None. The top 2 bits came from pad_to_byte
EngineSpeed0x2B0, 7\16@0+, factor 0.25, offset 00x2B0, 7\16@0+, factor 0.25, offset 2Offset of 2 rpm, below the 12 rpm noise

The RMS errors are what the references allow. OBD-II speed is a whole number of km/h, and rounding to whole numbers alone leaves an RMS error of about 0.29 km/h. The engine speed in the log has ±15 rpm of noise from frame to frame. The whole pipeline runs in under a second on this log.

What it did not find is just as important:

  • The wheel speeds tie with vehicle speed. All five fields correlate at 0.998 or better. Statistics cannot say which one the dashboard shows; that needs another test, such as driving a tight circle and watching the left and right wheels separate.
  • Door, brake pedal, coolant and outside temperature do not rank near the top for either reference. Each needs its own reference or a controlled test: open the door, press the pedal.
  • Counters and CRCs are found by the survey, not by correlation.

Where the LLM fits

An LLM agent is useful here for the same reasons a colleague would be: it can run scripts, read their output, spot that four fields move together, and suggest the next test. It is not useful as a calculator or as a reader of raw logs. The log above is 2.3 MB of hex; the survey and ranking output that carries the evidence is under 2 KB. Give the agent the scripts and their summaries, not the log.

Rules that keep its output checkable:

  1. Every number comes from a script. Start bits, factors and R² values the model states without running code are guesses.
  2. Every accepted signal has a held-out score. Fit on one part of the log, check on another.
  3. Names are hypotheses until a test confirms them. "Four 16-bit values at 20 ms that track speed" suggests wheel speeds; a turning test proves it.
  4. Ties are reported, not resolved by preference.

A prompt for a coding agent working in the folder with the scripts:

Example
You are helping reverse engineer CAN signals. Work only through the scripts in this folder.
1. Run `python3 re_pipeline.py`. Do not open synthetic.log or any other log directly.
2. For each reference, report the CAN ID, start bit, length, byte order, factor, offset,
   held-out R² and RMS error exactly as the script printed them.
3. If several fields score within 0.001 of each other, list all of them and propose a
   driving or bench test that would tell them apart.
4. Suggest DBC names only for fields with held-out R² above 0.99, and mark each name
   as a hypothesis.
5. List the bytes with a change rate above 0.05 that matched no reference, and say which
   reference signal or controlled test could explain each one.

The same split works for the other steps. Let the agent write a new reference extractor, for example for PID 05 coolant temperature, then run the same search with it.

Limits to keep in mind

  • No reference, no name. A signal with nothing to compare against can be bounded, not identified.
  • One reference can match many fields. Vehicle speed, wheel speeds and a displayed speed all correlate with OBD-II speed.
  • Slow and rare signals need long logs. A value that changes only a few times per drive gives the correlation very few points to work with.
  • Timing matters. References arrive later than the frames they describe. This pipeline times OBD-II values at their request; other references need their own lag check.
  • Synthetic results are a best case. Real logs add filtering, quantisation and missing frames. Always score on held-out data from the real vehicle.

Frequently asked questions

Can AI reverse engineer CAN bus signals?

Partly. Statistical methods published since 2018 find signal boundaries, byte order and signedness automatically, and match fields against a reference such as OBD-II data. An LLM agent can run these steps and interpret the results. Naming a signal still needs a reference or a controlled test.

What reference signal should I use for CAN reverse engineering?

One you can log at the same time as the bus and whose meaning is certain. OBD-II PIDs such as vehicle speed and engine speed are the easiest: their formulas are standardised and you read them from the same port. GPS speed or a value read from the dashboard also works.

Should I paste my CAN log into ChatGPT or Claude?

Not the raw log. A few minutes of traffic is megabytes of hex. Run the analysis scripts and give the model their summaries, then make it confirm every claim by running code.

How do I know a reverse-engineered signal is right?

Fit it on one part of the log and check it on another. A held-out R² close to 1 and an error close to the reference's own resolution are good signs. Then check it on a fresh recording from another drive.

References