
Research
SANDWORM_MODE: Shai-Hulud-Style npm Worm Hijacks CI Workflows and Poisons AI Toolchains
An emerging npm supply chain attack that infects repos, steals CI secrets, and targets developer AI toolchains for further compromise.
pya2ldb
Advanced tools
|PyPI| |Python Versions| |License: LGPL v3+| |Code style: black|
.. image:: pya2l_social.jpg :align: center
pyA2L is an ASAM MCD-2MC <https://www.asam.net/standards/detail/mcd-2-mc/>__ processing
library written in Python.
If you work with ECUs, ASAP2/A2L is the contract that describes what and how to measure or calibrate. pyA2L helps you parse once, inspect and validate programmatically, automate checks, and export back when needed — all from Python.
ASAM MCD-2 MC (ASAP2) is the ASAM standard that defines the A2L description format for ECU measurement signals and calibration parameters. In practice, the A2L acts as a contract between ECU software and tools so different vendors can consistently locate data in memory and convert raw values into physical engineering units. Runtime transport (e.g., CCP/XCP) is out of scope of the standard.
For an authoritative overview of the standard, see the ASAM page: https://www.asam.net/standards/detail/mcd-2-mc/
Supported ASAP2 version: 1.6.
pya2l.api.inspectpya2l.api.validate yielding structured
diagnosticsLearn more about the standard at the ASAM website: https://www.asam.net/standards/detail/mcd-2-mc/wiki/
Via pip: shell $ pip install pya2ldb IMPORTANT:
Package-name is pya2ldb NOT pya2l!!!
From Github:
pyA2Ldb repository <https://github.com/christoph2/pya2l>__.Parse once, work from SQLite thereafter.
Import a .a2l file and persist it as .a2ldb (SQLite):
.. code:: python
from pya2l import DB
db = DB() session = db.import_a2l( "ASAP2_Demo_V161.a2l", # Optional: # encoding="utf-8", # default is latin-1 # progress_bar=False, # silence the progress meter # loglevel="ERROR", # also suppresses progress )
.. code:: python
from pya2l import DB
db = DB() session = db.open_existing("ASAP2_Demo_V161") # extension .a2ldb is implied
Query with SQLAlchemy ORM - List all measurements ordered by name with address and data type:
.. code:: python
from pya2l import DB import pya2l.model as model
db = DB() session = db.open_existing("ASAP2_Demo_V161") measurements = ( session.query(model.Measurement) .order_by(model.Measurement.name) .all() ) for m in measurements: print(f"{m.name:48} {m.datatype:12} 0x{m.ecu_address.address:08x}")
High-level inspection helpers - Use convenience wrappers from pya2l.api.inspect to access derived info:
.. code:: python
from pya2l import DB from pya2l.api.inspect import Characteristic, Measurement, AxisDescr
db = DB() session = db.open_existing("ASAP2_Demo_V161") ch = Characteristic(session, "ASAM.C.MAP.UBYTE.IDENTICAL") print("shape:", ch.dim().shape) print("element size:", ch.fnc_element_size(), "bytes") print("num axes:", ch.num_axes())
me = Measurement(session, "ASAM.M.SCALAR.UBYTE.IDENTICAL") print("is virtual:", me.is_virtual())
axis = ch.axisDescription("X") print("axis info:", axis.axisDescription("X"))
Validate your database
.. code:: python
from pya2l import DB from pya2l.api.validate import Validator
db = DB() session = db.open_existing("ASAP2_Demo_V161") vd = Validator(session) for msg in vd(): # iterate diagnostics # msg has fields: type (Level), category (Category), diag_code (Diagnostics), text (str) print(msg.type.name, msg.category.name, msg.diag_code.name, "-", msg.text)
Export back to A2L (optional)
.. code:: python
from pya2l import export_a2l
export_a2l("ASAP2_Demo_V161", "exported.a2l")
encoding= if your file differs.progress_bar=False or loglevel="ERROR".pya2ldb (not pya2l).howto <./howto.rst>__ for Excel export and other short recipes.pya2l/examples for sample A2L files and scripts.pyA2L offers a Creator API in pya2l.api.create to programmatically build or augment A2L content. The project’s goal is coverage parity: everything you can query via pya2l.api.inspect is intended to be creatable via pya2l.api.create.
Example: creating common entities
.. code:: python
from pya2l import DB from pya2l.api.create import ModuleCreator from pya2l.api.inspect import Module
session = DB().open_create("MyProject.a2l") # or .a2ldb
mc = ModuleCreator(session)
mod = mc.create_module("DEMO", "Demo ECU module")
temp_unit = mc.add_unit(mod, name="degC", long_identifier="Celsius", display="°C", type_str="TEMPERATURE") ct = mc.add_compu_tab(mod, name="TAB_NOINTP_DEMO", long_identifier="Demo Tab", conversion_type="TAB_NOINTP", pairs=[(0, 0.0), (100, 1.0)], default_numeric=0.0)
fr = mc.add_frame(mod, name="FRAME1", long_identifier="Demo frame", scaling_unit=1, rate=10, measurements=["ENGINE_SPEED"]) tr = mc.add_transformer(mod, name="TR1", version="1.0", dllname32="tr32.dll", dllname64="tr64.dll", timeout=1000, trigger="ON_CHANGE", reverse="NONE", in_objects=["ENGINE_SPEED"], out_objects=["SPEED_PHYS"])
ts = mc.add_typedef_structure(mod, name="TSig", long_identifier="Signal", size=8) mc.add_structure_component(ts, name="raw", type_ref="UWORD", offset=0) inst = mc.add_instance(mod, name="S1", long_identifier="Inst of TSig", type_name="TSig", address=0x1000)
mi = Module(session) print("#frames:", len(list(mi.frame.query()))) print("#compu tabs:", len(list(mi.compu_tab.query())))
See pya2l/examples/create_quickstart.py for a more complete example.
A small CLI is provided as a console script named a2ldb-imex:
.. code:: bash
$ a2ldb-imex -V
$ a2ldb-imex -i path/to/file.a2l
$ a2ldb-imex -i path/to/file.a2l -E latin-1 -L
$ a2ldb-imex -e path/to/file.a2ldb -o exported.a2l
Documentation <index.rst>__Contributions are welcome! Please open an issue to discuss significant
changes before submitting a PR. See the existing tests under
pya2l/tests and examples under pya2l/examples to get started.
Contributors should use pre-commit to run formatting and lint checks
before committing; see https://pre-commit.com/ for installation and
usage.
This project follows a Code of Conduct to foster an open and welcoming community. Please read and abide by it when interacting in issues, discussions, and pull requests.
See CODE_OF_CONDUCT <../CODE_OF_CONDUCT.md>__ for full details.
See GitHub Releases: https://github.com/christoph2/pyA2L/releases
.. |CI| image:: https://github.com/christoph2/pya2l/workflows/Python%20application/badge.svg :target: https://github.com/christoph2/pya2l/actions .. |PyPI| image:: https://img.shields.io/pypi/v/pya2ldb.svg :target: https://pypi.org/project/pya2ldb/ .. |Python Versions| image:: https://img.shields.io/pypi/pyversions/pya2l.svg :target: https://pypi.org/project/pya2ldb/ .. |License: LGPL v3+| image:: https://img.shields.io/badge/License-LGPL%20v3%2B-blue.svg :target: https://www.gnu.org/licenses/lgpl-3.0 .. |Code style: black| image:: https://img.shields.io/badge/code%20style-black-000000.svg :target: https://github.com/psf/black
FAQs
A2L for Python
We found that pya2ldb demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Research
An emerging npm supply chain attack that infects repos, steals CI secrets, and targets developer AI toolchains for further compromise.

Company News
Socket is proud to join the OpenJS Foundation as a Silver Member, deepening our commitment to the long-term health and security of the JavaScript ecosystem.

Security News
npm now links to Socket's security analysis on every package page. Here's what you'll find when you click through.