pyA2L is an ASAM MCD-2MC processing library written in Python.
ASAM MCD-2MC, also known as ASAP2, is a non-XML file format for defining calibration parameters, measureable variables, and communication interface specific parameters, widely used in automotive applications.
ASAP2 is typically used together with CCP (CAN Calibration Protocol) or XCP (Universal Calibration Protocol).
Supported Versions: 1.6
-
Via
pip:$ pip install pya2ldb
IMPORTANT: Package-name is
pya2ldbNOTpya2l!!! -
From Github:
- Clone / fork / download pyA2Ldb repository.
- Make sure you have a working Java installation on your system, like AdoptOpenJDK or OpenJDK.
- Download and install
ANTLR 4.11.1:curl -O -C - -L https://www.antlr.org/download/antlr-4.11.1-complete.jar- Add
ANTLRto yourCLASSPATHenvironment variable, e.g.:export CLASSPATH=$CLASSPATH:~/jars/antlr-4.11.1-complete.jar(you may put this in your.bashrc,.zshrc, ...).
- Run setup-script:
python setup.py develop
here is a basic example:
from pya2l import DB
import pya2l.model as model
db = DB()
base_dir = "examples/"
a2l_file = "ASAP2_Demo_V161"
try:
session = db.import_a2l(f"{base_dir}{a2l_file}.a2l")
except OSError:
print("a2ldb for this file already exists, using it instead")
session = db.open_existing(f"{base_dir}{a2l_file}.a2ldb")
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}")