MCPcopy Index your code
hub / github.com/DanielT/autosar-data

github.com/DanielT/autosar-data @v0.22.0

Chat with this repo
repository ↗ · DeepWiki ↗ · release v0.22.0 ↗ · + Follow
597 symbols 2,395 edges 20 files 185 documented · 31%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

autosar-data

Github Actions codecov license

This crate provides functionality to read, modify and write Autosar 4 arxml files, both separately and in projects consisting of multiple files.

The crate autosar-data-abstraction provides an abstraction layer on top of this crate.

There is also a Python module which is based on this crate: autosar-data-py PyPI version

Features

  • read and write arxml files
  • fully validate all data when it is loaded
  • non-strict mode so that invalid but structurally sound data can be loaded
  • various element operations to modify and create sub-elements, data and attributes
  • support for Autosar paths and cross references
  • all operations are thread safe, e.g. it is possible to load mutliple files on separate threads
  • supports Autosar version 4.0.1 and up.

Example

use autosar_data::*;

/* load a multi-file data model */
let model = AutosarModel::new();
let (file_1, warnings_1) = model.load_file("some_file.arxml", false)?;
let (file_2, warnings_2) = model.load_file("other_file.arxml", false)?;

/* load a buffer */
let (file_3, _) = model.load_buffer(buffer, "filename.arxml", true)?;

/* write all files of the model */
model.write()?;

/* alternatively: */
for file in model.files() {
    let file_data = file.serialize();
    // do something with file_data
}

/* iterate over all elements in all files */
for (depth, element) in model.elements_dfs() {
    if element.is_identifiable() {
        /* the element is identifiable using an Autosar path */
        println!("{depth}: {}, {}", element.element_name(), element.path()?);
    } else {
        println!("{depth}: {}", element.element_name());
    }
}

/* get an element by its Autosar path */
let pdu_element = model.get_element_by_path("/Package/Mid/PduName").unwrap();

/* work with the content of elements */
if let Some(length) = pdu_element
    .get_sub_element(ElementName::Length)
    .and_then(|elem| elem.character_data())
    .and_then(|cdata| cdata.string_value())
{
    println!("Pdu Length: {length}");
}

/* modify the attributes of an element */
pdu_element.set_attribute_string(AttributeName::Uuid, "12ab34cd-1234-1234-1234-12ab34cd56ef");
pdu_element.remove_attribute(AttributeName::Uuid);

Example Programs

Two complete example programs can be found in the examples directory of the source repostitory. They are:

  • businfo, which extracts information about bus settings, frames, pdus and signals from an autosar ECU extract
  • generate_files, which for each Autosar version generates an arxml file containing a least one instance of every specified element

License

Licensed under either of

Core symbols most depended-on inside this repo

get_sub_element
called by 189
autosar-data/src/element.rs
create_sub_element
called by 187
autosar-data/src/element.rs
create_named_sub_element
called by 104
autosar-data/src/element.rs
character_data
called by 90
autosar-data/src/element.rs
write
called by 80
autosar-data/src/autosarmodel.rs
root_element
called by 75
autosar-data/src/autosarmodel.rs
find_sub_element
called by 68
autosar-data-specification/src/lib.rs
create_file
called by 65
autosar-data/src/autosarmodel.rs

Shape

Method 280
Function 262
Class 35
Enum 20

Languages

Rust100%

Modules by API surface

autosar-data/src/element.rs121 symbols
autosar-data-specification/src/lib.rs68 symbols
autosar-data/src/autosarmodel.rs64 symbols
autosar-data-specification/src/regex.rs56 symbols
autosar-data/src/parser.rs55 symbols
autosar-data/src/elementraw.rs40 symbols
autosar-data/examples/businfo/main.rs35 symbols
autosar-data/src/arxmlfile.rs29 symbols
autosar-data/src/chardata.rs27 symbols
autosar-data/src/lib.rs26 symbols
autosar-data/src/lexer.rs23 symbols
autosar-data/src/iterators.rs14 symbols

For agents

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

⬇ download graph artifact