MCPcopy Index your code
hub / github.com/DanielT/a2lfile

github.com/DanielT/a2lfile @v3.4.0

Chat with this repo
repository ↗ · DeepWiki ↗ · release v3.4.0 ↗ · + Follow
815 symbols 2,752 edges 30 files 163 documented · 20%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

a2lfile

Github Actions codecov license

a2lfile is a library that allows you to read, modify and write a2l files.

Features

  • full support for files using A2L version 1.7.1
  • it is fast
  • the layout and format of the input file is preserved. The intention is that after reading, modifying and then writing a file the resulting diff should be minimal
  • easy access to application-specific data inside of IF_DATA blocks is provided through a macro that generates code based on an A2ML specification

What is an a2l file

A2l files are commonly used during the development and testing of automotive ECUs. The consumer of the a2l file typically performs online calibration over a protocol such as XCP and/or offline tuning by generating flashable parameter sets.

If you have never seen an a2l file then you are unlikely to need this library.

Tools

The program a2ltool is based on this library.

Documentation

A simple program based on the a2lfile library might look like this:

use a2lfile::*;

fn main() {
    let input_filename = &std::ffi::OsString::from("example.a2l");
    let mut logmsgs = Vec::<A2LError>::new();
    let mut a2l_file = a2lfile::load(
        input_filename,
        None,
        &mut logmsgs,
        false
    ).expect("could not load the file");
    for log_msg in logmsgs {
        println!("warning while loading the file: {}", log_msg);
    }

    // perform a consistency check
    let mut logmsgs = Vec::<String>::new();
    a2l_file.check(&mut logmsgs);
    for log_msg in logmsgs {
        println!("warning during consistency check: {}", log_msg);
    }

    for measurement in &a2l_file.project.module[0].measurement {
        // do something with the MEASUREMENT objects in the file
        println!("MEASUREMENT: {:#?}", measurement);
    }

    // create a new CHARACTERISTIC object
    let new_characteristic = Characteristic::new(
        "my_name".to_string(),
        "my extended description".to_string(),
        CharacteristicType::Value,
        0x12345678,
        "something.RECORD_LAYOUT".to_string(),
        0.0,
        "NO_COMPU_METHOD".to_string(),
        0.0,
        100.0
    );
    a2l_file.project.module[0].characteristic.push(new_characteristic);


    // update the sorting to find a suitable insertion point for the new characteristic - by default it will be placed at the end
    a2l_file.sort_new_items();

    // write the modified file
    a2l_file.write(
        &std::ffi::OsString::from("example_output.txt"),
        Some("modified by the demo program")
    ).expect("failed to write output");
}

License

Licensed under either of

Extension points exported contracts — how you extend this code

A2lObject (Interface)
The trait `A2lObject` is implemented for all a2l objects as well as all objects generated by the `a2ml_specification`! m [169 …
a2lfile/src/specification.rs
A2lObjectName (Interface)
The trait `A2lObjectName` is automatically implemented for named a2l objects [39 implementers]
a2lfile/src/specification.rs
A2lObjectNameSetter (Interface)
The trait `A2lObjectName` is automatically implemented for named a2l objects [36 implementers]
a2lfile/src/specification.rs
PositionRestricted (Interface)
(no doc) [165 implementers]
a2lfile/src/specification.rs
ParseableA2lObject (Interface)
(no doc) [187 implementers]
a2lfile/src/specification.rs

Core symbols most depended-on inside this repo

new
called by 1865
a2lfile/src/lib.rs
push
called by 856
a2lfile/src/itemlist.rs
get_line_offset
called by 404
a2lfile/src/parser.rs
finish
called by 338
a2lfile/src/writer.rs
handle_multiplicity_error
called by 272
a2lfile/src/parser.rs
require_keyword
called by 244
a2lfile/src/parser.rs
get_next_id
called by 215
a2lfile/src/parser.rs
get_incfilename
called by 179
a2lfile/src/parser.rs

Shape

Function 397
Class 194
Method 178
Enum 36
Interface 10

Languages

Rust100%

Modules by API surface

a2lfile/src/specification.rs244 symbols
a2lfile/src/parser.rs68 symbols
a2lfile/src/merge.rs59 symbols
a2lfile/src/a2ml.rs53 symbols
a2lmacros/src/a2mlspec.rs48 symbols
a2lfile/src/checker.rs40 symbols
a2lfile/src/itemlist.rs35 symbols
a2lfile/src/lib.rs30 symbols
a2lfile/src/writer.rs24 symbols
a2lfile/src/tokenizer.rs24 symbols
a2lfile/src/specification_orig.rs24 symbols
a2lfile/src/module.rs18 symbols

For agents

$ claude mcp add a2lfile \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact