Skip to main content

Vehicle description file handling for Python

Project description

pyDBC

Build status Maintainability Build Status

GPL License

pyDBC is a library for creating and editing automotive network description files, including:

  • DBC (CAN Database) files for CAN bus systems
  • LDF (LIN Description File) for LIN networks
  • NCF (Network Configuration File) for vehicle network configurations

Installation

pyDBC is hosted on Github, get the latest release: https://github.com/christoph2/pydbc

Using Poetry (recommended)

This project uses Poetry for dependency management and packaging. If you don't have Poetry installed, you can install it by following the instructions on the Poetry website.

# Install the package
poetry install

# Run the tests
poetry run pytest

Requirements

  • Python >= 3.10
  • SQLAlchemy >= 2.0.0
  • Other dependencies are managed by Poetry

First steps

pyDBC provides high-level creational APIs for working with automotive network description files. These APIs make it easy to create and manipulate DBC, LDF, and NCF components.

Creating a CAN database (DBC)

from pydbc.api.dbc import DBCCreator

# Create a new DBC creator with an in-memory database
dbc = DBCCreator(":memory:")

# Create nodes (ECUs)
engine = dbc.create_node("Engine")
gateway = dbc.create_node("Gateway")

# Create a message
engine_data = dbc.create_message("EngineData", 100, 8, engine)

# Create signals
petrol_level = dbc.create_signal(
    "PetrolLevel", 8, byteorder=1, sign=1,
    formula_factor=1.0, formula_offset=0.0,
    minimum=0, maximum=255, unit="l"
)

# Add signals to messages
dbc.add_signal_to_message(engine_data, petrol_level, 24)

# Add signal receivers
dbc.add_node_as_receiver(petrol_level, gateway)

# Commit changes to the database
dbc.commit()

Creating a LIN network (LDF)

from pydbc.api.ldf import LDFCreator

# Create a new LDF creator with an in-memory database
ldf = LDFCreator(":memory:")

# Create a LIN network
network = ldf.create_network(
    "LINNetwork1",
    protocol_version="2.1",
    speed=19.2
)

# Create master and slave nodes
master = ldf.create_master_node("MasterECU", timebase=0.005, jitter=0.0001)
slave = ldf.create_slave_node("SlaveNode1", configured_NAD=1)

# Create signals and frames
signal = ldf.create_signal("MotorSpeed", signal_size=16, init_value=0, publisher=master)
frame = ldf.create_unconditional_frame("MasterFrame", frame_id=0x10, size=2, publisher=master)

# Add signals to frames
ldf.add_signal_to_frame(frame, signal, 0)

# Commit changes to the database
ldf.commit()

Creating a network configuration (NCF)

from pydbc.api.ncf import NCFCreator

# Create a new NCF creator with an in-memory database
ncf = NCFCreator(":memory:")

# Create a vehicle
vehicle = ncf.create_vehicle("TestVehicle")

# Create networks and ECUs
can_network = ncf.create_network("CANNetwork", protocol="CAN", speed=500)
engine_ecu = ncf.create_ecu("EngineECU")

# Add networks to vehicle
ncf.add_network_to_vehicle(vehicle, can_network)

# Add ECUs to vehicle
ncf.add_ecu_to_vehicle(vehicle, engine_ecu)

# Commit changes to the database
ncf.commit()

For more detailed examples, see the pydbc/examples/api_examples.py file.

Features

  • High-level creational APIs for DBC, LDF, and NCF components
  • SQLAlchemy-based database model for storing network configurations
  • Support for all major components of automotive network description files
  • Comprehensive examples demonstrating API usage

Documentation

The full documentation in GitHub‑Flavored Markdown is available in the docs/ folder:

  • docs/INDEX.md — Documentation home
  • docs/getting-started.md — Installation and quickstarts
  • docs/tutorial.md — Step‑by‑step walkthrough
  • docs/how-to.md — Task‑oriented guides
  • docs/examples.md — Ready‑to‑run examples
  • docs/api-reference.md — API reference
  • docs/python-can.md — Using pyDBC with python-can (send/receive CAN frames)

License

GNU General Public License v2.0

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyvndb-1.0.114.tar.gz (149.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyvndb-1.0.114-py3-none-any.whl (180.4 kB view details)

Uploaded Python 3

File details

Details for the file pyvndb-1.0.114.tar.gz.

File metadata

  • Download URL: pyvndb-1.0.114.tar.gz
  • Upload date:
  • Size: 149.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pyvndb-1.0.114.tar.gz
Algorithm Hash digest
SHA256 46c4318475324ce9182ff58b0541c2cce326a8c49fc2b0fee7fff495f4b1dfee
MD5 804ffed98fe0af8d8acfd8f2f4738f12
BLAKE2b-256 a0e48c1fc4e57725bbeb32ee25319926cf0f57e80460432ee05a7cd1f997ebae

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyvndb-1.0.114.tar.gz:

Publisher: pythonapp.yml on christoph2/pydbc

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyvndb-1.0.114-py3-none-any.whl.

File metadata

  • Download URL: pyvndb-1.0.114-py3-none-any.whl
  • Upload date:
  • Size: 180.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pyvndb-1.0.114-py3-none-any.whl
Algorithm Hash digest
SHA256 5797a07409e7a1e8c55fc3593dbb86836de6ecbba81a90970be736913d41b9c4
MD5 9732caf0bc0c8be4be5adc1d32d48b6b
BLAKE2b-256 51b1ed5bf25de7ed90a4d85a700a2b2fd79035e242326536caf3b0a1aa54b8ab

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyvndb-1.0.114-py3-none-any.whl:

Publisher: pythonapp.yml on christoph2/pydbc

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page