A command-line toolkit for working with A2L files for ECU tuning. This toolkit helps in preparing A2L files for further processing, creates a database representation of the A2L data, exports the data to JSON format, and can generate C header files for direct memory access.
- Preprocesses A2L files to ensure compatibility
- Creates a database representation of the A2L data
- Exports A2L data to JSON format for easier processing
- Generates C header files with memory address definitions
- Command-line interface for easy integration into workflows
- Supports custom output file naming
- Includes header guards and proper C types based on variable sizes
- Python 3.6 or higher
- Required Python packages (install via pip):
- pya2l
- chardet
- Clone this repository:
git clone https://github.com/yourusername/A2L-Convert.git
cd A2L-Convert- Install the required packages:
pip install -r requirements.txtBasic usage:
python import-a2l.py input_file.a2lThis will create a preprocessed file with "_preprocessed" suffix in the same directory.
To specify a custom output file:
python import-a2l.py input_file.a2l -o output_file.a2lBasic usage:
python export-json.py input_file.a2lThis will create a JSON file with the same name as the input file but with a .json extension.
To specify a custom output file:
python export-json.py input_file.a2l -o output_file.jsonBasic usage:
python json_to_c-header.py input_file.jsonThis will create a C header file with the same name as the input file but with a .h extension.
To specify a custom output file:
python json_to_c-header.py input_file.json -o output_file.hThe generated header file includes:
- Header guards
- Proper C types based on variable sizes (uint8_t, uint16_t, etc.)
- Memory address definitions with volatile pointers
- Bit mask support for bitfield access
- Original variable descriptions as comments
For import-a2l.py:
input_file: Path to the input A2L file (required)-o, --output: Path to the output preprocessed A2L file (optional)-h, --help: Show help message and exit
For export-json.py:
input_file: Path to the preprocessed A2L file (required)-o, --output: Path to the output JSON file (optional)-h, --help: Show help message and exit
For json_to_c-header.py:
input_file: Path to the input JSON file (required)-o, --output: Path to the output header file (optional)-h, --help: Show help message and exit
- First, preprocess your A2L file:
python import-a2l.py your_file.a2l- Then export the data to JSON:
python export-json.py your_file_preprocessed.a2l- Finally, generate the C header file:
python json_to_c-header.py your_file.jsonAll tools include error handling for common issues:
- Missing input files
- Processing errors
- File access problems
- Database errors
- JSON parsing errors
- Invalid data types or sizes
Error messages will be displayed in the console with appropriate exit codes.
[Add your chosen license here]
Contributions are welcome! Please feel free to submit a Pull Request.