Skip to main content

dbckit

PyPI CI Python versions Downloads License: MIT

dbckit is a Python library for working with DBC (CAN database) files.

Use it to:

  • load and inspect DBC files
  • decode CAN payloads into physical signal values — integers, floats, and doubles
  • encode signal values back into CAN payloads
  • validate DBC content
  • apply deterministic edits and write the result back out
  • diff, merge, extract, and search databases
  • decode CAN log files (.asc built in, extensible readers) and in-memory frame streams

dbckit signal layout rendering a colored bit grid of the VehicleSpeed message in the terminal

Output of dbckit signal layout — per-signal colored bit grid of a message.

Install

pip install dbckit
pip install "dbckit[cli]"   # adds the dbckit command-line tool

Requires Python >=3.11.

Design

dbckit is built around typed data models with database-bound Views:

  • Database is for navigation, top-level creation, cross-database operations, and persistence.
  • MessageView, SignalView, and NodeView (returned by db.message(), msg.signal(), db.node()) are the normal way to modify or delete existing entities.
  • Edit operations are copy-on-write: they return a new Database and never mutate the original.

Quick Start

import dbckit

db = dbckit.load("vehicle.dbc")

# inspect
print(db.version, len(db.messages))

msg = db.message(0x1F4)
sig = msg.signal("EngineSpeed")
print(sig.start_bit, sig.length, sig.factor, sig.unit)

# decode / encode a frame payload
values = msg.decode(bytes([0xE8, 0x03, 0, 0, 0, 0, 0, 0]))
raw = msg.encode({"EngineSpeed": 825.0, "EngineTemp": 90.0})

# validate
for issue in dbckit.validate(db):
    print(issue.severity, issue.code, issue.location)

# edits return a new Database
db2 = sig.update(factor=0.5)
db3 = db2.message(0x1F4).rename("MotorData")
db4 = db3.node("ECU1").rename("EngineECU")

db4.save("vehicle.updated.dbc")

Features

Parse and I/O

dbckit.load() / dbckit.save() for files, dbckit.parse() / dbckit.dump() for strings. Loading tries strict UTF-8 first and falls back to cp1252 (common in Vector-exported files); pass encoding= to either function to force one:

db = dbckit.load("vehicle.dbc", encoding="latin-1")
dbckit.save(db, "copy.dbc", encoding="utf-8")

For bounded unsupported constructs, on_unsupported="skip" returns the parseable model with structured diagnostics and decode-safety rollups; see the API reference.

Codec

Message-level decode_frame() / encode_frame() and signal-level decode_signal() / encode_signal(). Both integer signals and IEEE-754 float/double signals (SIG_VALTYPE_) are supported, in Intel and Motorola byte order. Encoding clamps out-of-range values by default; pass strict=True to raise ValueError instead. Unspecified signals are zero-filled.

Simple DBC multiplexing (one M selector, mX variants) is fully supported for decode, encode, and validation. Extended/nested multiplexing (m0M) is unsupported and rejected during parsing with a clear error.

Editing

Views cover renames, field updates, signal add/delete, sender and receiver edits, arbitration-ID changes, value-table choices, and attribute values. Database covers top-level creation and signal groups:

from dbckit import Message, Signal, Node, SignalGroup

db2 = db.add_node(Node(name="Gateway"))
db3 = db2.add_message(Message(arbitration_id=0x400, name="BrakeData", length=8))
db4 = db3.message(0x400).add_signal(Signal(name="BrakePressure", start_bit=0, length=16))
db5 = db4.message(0x400).set_attribute("GenMsgCycleTime", 20)
db6 = db5.add_signal_group(SignalGroup(name="BrakeGroup", message_id=0x400, repetitions=1))
db7 = db6.add_signal_to_group(0x400, "BrakeGroup", "BrakePressure")
db7.save("vehicle.updated.dbc")

Validation

dbckit.validate(db) returns structured issues (severity, code, location, message) covering duplicate/invalid IDs, signal overlap and overflow, multiplexing problems, missing senders/receivers, and attribute violations. The full issue-code list is in the API reference.

Operations

result = dbckit.diff(db_a, db_b)
merged = dbckit.merge(db_a, db_b, strategy="ours")   # raise | ours | theirs

sub = dbckit.extract(db, [0x100, 0x200])
sub = dbckit.extract(db, message_names=["EngineData"], node_names=["Gateway"])

messages = dbckit.search_messages(db, "engine")
pairs = dbckit.search_signals(db, "speed")

J1939 lookup helpers continue to use explicit PGN/SPN attribute values. For frame resolution, pgn_from_arbitration_id() derives the PGN directly from a 29-bit ID with PDU1/PDU2 handling:

matches = dbckit.find_messages_by_pgn(db, 61444)
owner, sig = db.signal_by_spn(177)
pgn = dbckit.pgn_from_arbitration_id(0x18F00401)  # 61444

Log and frame decoding

decode_log() streams decoded frames from a log file. Vector CANalyzer .asc is built in (including extended 29-bit IDs); other formats plug in through register_reader() or the dbckit.readers entry-point group, and format= overrides extension-based detection for oddly named files:

for frame in dbckit.decode_log(db, "trace.asc"):
    print(frame.timestamp, hex(frame.arbitration_id), frame.signals)

frames = dbckit.decode_log(db, "capture.txt", format="asc")

decode_frames() does the same for any iterable of frame objects — no file I/O required. Anything with timestamp, arbitration_id, and data attributes satisfies the FrameLike protocol, so frames from python-can or your own tooling decode directly:

decoded = dbckit.decode_frames(db, my_frames)   # Iterator[DecodedFrame]

# Resolve J1939 frames by derived PGN; ambiguous matches are returned explicitly.
decoded = dbckit.decode_frames(db, my_frames, match="j1939")

# Prefer exact IDs, then allow PGN fallback only for a J1939-marked DBC.
decoded = dbckit.decode_frames(db, my_frames, match="auto")

Code generation

header = dbckit.codegen(db, "c")          # experimental
module = dbckit.codegen(db, "python")     # dataclasses with decode()/encode()
doc = dbckit.codegen(db, "markdown")
schema = dbckit.codegen(db, "json-schema")

CLI

The cli extra installs a dbckit command with db, message, signal, node, attribute, decode, encode, and codegen groups. Output formats are table, json, and csv.

dbckit db info --db vehicle.dbc
dbckit db validate --db vehicle.dbc
dbckit db diff base.dbc changed.dbc
dbckit message list --db vehicle.dbc
dbckit signal layout --db vehicle.dbc 0x1F4
dbckit decode frame --db vehicle.dbc 0x1F4 "E8 03 00 00 00 00 00 00"
dbckit decode log --db vehicle.dbc trace.asc --match auto
dbckit codegen markdown --db vehicle.dbc --out docs.md

See the CLI reference for every command and option.

Scope and Caveats

  • Classic CAN DBC workflows are the supported surface; CAN FD is untested and FD-specific flags such as VFrameFormat are not interpreted.
  • .sym, .kcd, and ARXML database formats are out of scope.
  • J1939 lookup helpers use explicit PGN/SPN attribute values. Frame-stream matching can derive PGNs from 29-bit IDs with match="j1939"; match="auto" requires a valid message PGN or J1939 ProtocolType attribute marker.
  • Frame encoding zero-fills unspecified signals and ignores GenSigStartValue.
  • Mutation helpers are pure at the Database level, but the underlying Pydantic models are not frozen objects.

Documentation

  • Recipes — short, runnable patterns for common dbckit tasks
  • API reference — the detailed public API contract, including codec overflow/error behavior and validation issue codes
  • DBC support matrix — which DBC sections and constructs are fully, partially, or not supported
  • CLI reference — every command and option

Development

python -m venv .venv
source .venv/bin/activate
pip install -e ".[dev]"
pytest

License

MIT

Metadata

Release files for dbckit 1.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for dbckit 1.1.1
File Size Uploaded Provenance
dbckit-1.1.1.tar.gz 146.0 kB With provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for dbckit 1.1.1
File Interpreter ABI Platform
dbckit-1.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 214.4 kB

Release files / dbckit-1.1.1.tar.gz

Download URL dbckit-1.1.1.tar.gz
Size 146.0 kB
Tags Source
SHA-256 checksum
How to use checksums
954172bbd68ca43bc892d89abc0c3db38580f81d3e26e24abbee8443dc7302e5
BLAKE2b-256 checksum
How to use checksums
87c2e19eded4547168cbc13fe72c83c528587a29ef6ad2ccd23eb87f1e054eb1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 20, 2026.

Transparency log

Release files / dbckit-1.1.1-py3-none-any.whl

Download URL dbckit-1.1.1-py3-none-any.whl
Size 68.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
05f8f6f7f5d68f9f9f6d8ae0897cf05b72fc89433c1949eecb68763a9ac27c19
BLAKE2b-256 checksum
How to use checksums
e99fe58a0f30b7039c16391276af4a398b83fa3ea92ba3189e74f092142a8ae5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 20, 2026.

Transparency log

Security for dbckit 1.1.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for dbckit-1.1.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 20, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page