Current collected state Current
Observed since 20 Oct, 16:33 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
Parse and model ASAP2 A2L files with bidirectional conversion
A comprehensive Python library for parsing and modeling ASAP2 (.a2l) files with bidirectional conversion capabilities. This library extracts A2L content into structured Python data models and supports exporting models back to A2L format.
Ensure Python 3.7+ is installed.
pip install pya2lmodel
from a2lparser import A2LParser, A2LModel
# Parse an A2L file
parser = A2LParser()
model = parser.parse_file("your_file.a2l")
# Access parsed data
print(f"Project: {model.project_name}")
print(f"Module: {model.module_name}")
print(f"Measurements: {len(model.measurements)}")
print(f"Characteristics: {len(model.characteristics)}")
print(f"DAQ events: {len(model.daq_events)}")
# Export to JSON-like dict
model_dict = model.to_dict()
import json
print(json.dumps(model_dict, indent=2))
# Export model to A2L string
a2l_content = model.to_a2l()
print("Generated A2L content:")
print(a2l_content[:500]) # Show first 500 characters
# Export directly to file
model.to_file("exported_file.a2l")
# Customize indentation
model.to_file("exported_file_spaces.a2l", indent=" ")
# Parse existing file
model = parser.parse_file("original.a2l")
# Modify data
if model.measurements:
model.measurements[0].description = "Modified measurement description"
# Add new characteristics
from a2lparser.a2l_model import Characteristic
new_char = Characteristic(
name="NEW_CALIBRATION",
description="New calibration parameter",
char_type="VALUE",
address=0x1000,
record_layout="RL_1D",
compu_method="CM_IDENTICAL",
lower_limit=0.0,
upper_limit=100.0
)
model.characteristics.append(new_char)
# Export modified model
model.to_file("modified.a2l")
parse_file(path: str | Path) -> A2LModel: Parse A2L file from pathparse_text(text: str) -> A2LModel: Parse A2L content from stringto_dict() -> Dict[str, Any]: Convert model to JSON-like dictionaryto_a2l(indent: str = "\t") -> str: Export to A2L format stringto_file(filepath: str, indent: str = "\t") -> None: Export to A2L fileProtocolLayer, DaqConfig, DaqEventXcpOnCanConfig, XcpOnCanFdConfigMemorySegment, SegmentInfo, PageInfoAxisPts, Measurement, CharacteristicCompuMethod, CompuVTabRecordLayout, Group, Function) for Windows compatibility
Project: MyECUProject
Module: ECU_Module
Protocol Layer parsed: True
DAQ events: 3
XCP on CAN parsed: True
Memory segments: 5
AXIS_PTS: 12
Measurements: 150
Characteristics: 80
Record layouts: 8
Generated A2L preview:
ASAP2_VERSION 1 70
/begin PROJECT "MyECUProject" ""
/begin HEADER ""
VERSION "1"
PROJECT_NO No
/end HEADER
/begin MODULE "ECU_Module" ""
/begin A2ML
/end A2ML
...
MIT
For issues or improvements, please raise an issue or contribute via pull requests.
Download counts and popularity will appear here as the collector receives them.
| Version | Published | Direct dependencies | Open version |
|---|---|---|---|
| 0.0.2 | 9 Nov 2025 | 6 |
This describes our collected data; it is not a security assessment.
Observed since 20 Oct, 16:33 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
package:c0f7f2908135da041473356fe073d649e4d21ea300ab1ccd06011908986933e6