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.115.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.115-py3-none-any.whl (180.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pyvndb-1.0.115.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.115.tar.gz
Algorithm Hash digest
SHA256 a181bfa87c40da34ed2fa612bac20612dab735b9598e0f3dd39dfa43bef488ba
MD5 e896d8b5d4d246dd8eeb205bb36edb93
BLAKE2b-256 3b73843dfe20b7c0345b07f49201d92f84f847d8989bd6c050ace437a5dbfa79

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyvndb-1.0.115.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.115-py3-none-any.whl.

File metadata

  • Download URL: pyvndb-1.0.115-py3-none-any.whl
  • Upload date:
  • Size: 180.3 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.115-py3-none-any.whl
Algorithm Hash digest
SHA256 5288ddc4c3aa3c15d46ed106ac54d7b9861944ed029ab01b5117442380b7c3f2
MD5 d6f1acd134246ec8b1ad17cfdc97be51
BLAKE2b-256 0b6fd6ff137b7982ac35834a0b33bcc218003c34737bcabe2bf3a2bd41a44a87

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyvndb-1.0.115-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