Skip to content

Commit

Permalink
Enable the use of response files
Browse files Browse the repository at this point in the history
The usual syntax of "@filename" is implemented to read arguments from "filename".
  • Loading branch information
DanielT committed Jul 14, 2024
1 parent 3255b5e commit 0ddd04e
Show file tree
Hide file tree
Showing 4 changed files with 84 additions and 9 deletions.
44 changes: 43 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "a2ltool"
version = "2.0.1"
version = "2.0.2"
authors = ["Daniel Thaler <daniel@dthaler.de>"]
edition = "2021"
license = "MIT OR Apache-2.0"
Expand All @@ -17,6 +17,7 @@ cpp_demangle = "0.4.3"
regex = "1"
indexmap = "2.2.0"
fxhash = "0.2.1"
argfile = { version ="0.2.0", features=["response"]}

[profile.release]
panic = "abort"
Expand Down
37 changes: 31 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,48 @@ A tool to edit, merge and update a2l files

`a2ltool file1.a2l --merge file2.a2l --output merged.a2l`

### Merge multiple a2l files

`a2ltool file1.a2l --merge file2.a2l --merge file3.a2l --merge file4.a2l --output merged.a2l`

### Merge all included files into the main file

`a2ltool file1.a2l --merge-includes --output flat.a2l`

### Update the addresses in an a2l file

`a2ltool input.a2l --elffile input.elf --update --output updated.a2l`

### Create a new a2lfile and add a characteristic from an elf file to it
### Update the addresses in an a2l file, while keeping invalid elements

`a2ltool input.a2l --elffile input.elf --update-preserve --output updated.a2l`

### Create a new a2l file and add a characteristic from an elf file to it

`a2ltool --create --elffile input.elf --characteristic my_var --output newfile.a2l`

### Create a new a2l file and add multiple measurements from an elf file to it using a regular expression

`a2ltool --create --elffile input.elf --measurement-regex ".*name_pattern\d\d+*" --output newfile.a2l`

### Create a new a2l file and add multiple measurements from an elf file to it using an address range

`a2ltool --create --elffile input.elf --measurement-range 0x1000 0x3000 --output newfile.a2l`

### Change the version of an a2l file, while deleting any incompatible elements

`a2ltool input.a2l --a2lversion 1.5.1 --output downgraded.a2l`

### Use response files containing command arguments

Assume that the file `a2ltool.rsp` exists and contains valid arguments for `a2ltool`.

`a2ltool @a2ltool.rsp`

## About a2l Files

A2l files describe measurement variables and tunable parameters of an embedded device (typically: an automotive ECU).

The consumer of the a2l file typically allows online calibraction over a protocol such as XCP and/or offline tuning by generating flashable parameter sets. There are several commercial tools for this purpose.

The a2l file format is specified by ASAM and is formally called ASAM MCD-2 MC.

## Project Status

With a2ltool version 1.0 all initially planned features were fully implemented.
Further improvements have been made as needed since then - see the changelog.
9 changes: 8 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use argfile;
use clap::{builder::ValueParser, parser::ValuesRef, Arg, ArgGroup, ArgMatches, Command};

use a2lfile::{A2lError, A2lFile, A2lObject};
Expand Down Expand Up @@ -541,6 +542,12 @@ fn load_or_create_a2l(
// set up the entire command line handling.
// fortunately clap makes this painless
fn get_args() -> ArgMatches {
let args = std::env::args_os();
let args = argfile::expand_args_from(args, argfile::parse_response, argfile::PREFIX)
.unwrap_or_else(|err| {
println!("invalid response file: {err}: {}", err.kind());
std::env::args_os().into_iter().collect()
});
Command::new("a2ltool")
.version(env!("CARGO_PKG_VERSION"))
.about("Reads, writes and modifies A2L files")
Expand Down Expand Up @@ -781,7 +788,7 @@ fn get_args() -> ArgMatches {
.multiple(true)
)
.next_line_help(false)
.get_matches()
.get_matches_from(args)
}

fn range_args_to_ranges(args: Option<ValuesRef<u64>>) -> Vec<(u64, u64)> {
Expand Down

0 comments on commit 0ddd04e

Please sign in to comment.