{"id":17511727,"url":"https://github.com/mercedes-benz/odxtools","last_synced_at":"2025-10-08T07:56:08.614Z","repository":{"id":38239444,"uuid":"386568904","full_name":"mercedes-benz/odxtools","owner":"mercedes-benz","description":"odxtools is a collection of utilities to interact with the diagnostic functionality of automotive electronic control units using python","archived":false,"fork":false,"pushed_at":"2025-04-02T16:52:34.000Z","size":3374,"stargazers_count":213,"open_issues_count":11,"forks_count":82,"subscribers_count":16,"default_branch":"main","last_synced_at":"2025-04-02T21:13:02.590Z","etag":null,"topics":["automotive-diagnostics","odx","python"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mercedes-benz.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-07-16T08:40:18.000Z","updated_at":"2025-04-02T16:52:09.000Z","dependencies_parsed_at":"2023-12-24T11:21:51.024Z","dependency_job_id":"cdcafa4f-65a8-4b99-9803-52fed9c623bb","html_url":"https://github.com/mercedes-benz/odxtools","commit_stats":{"total_commits":921,"total_committers":27,"mean_commits":"34.111111111111114","dds":"0.24212812160694897","last_synced_commit":"03a096f56072d5d72611dcaf1449b2731a2dba6a"},"previous_names":["daimler/odxtools"],"tags_count":99,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mercedes-benz%2Fodxtools","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mercedes-benz%2Fodxtools/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mercedes-benz%2Fodxtools/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mercedes-benz%2Fodxtools/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mercedes-benz","download_url":"https://codeload.github.com/mercedes-benz/odxtools/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248749408,"owners_count":21155677,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["automotive-diagnostics","odx","python"],"created_at":"2024-10-20T05:09:26.468Z","updated_at":"2025-10-08T07:56:08.595Z","avatar_url":"https://github.com/mercedes-benz.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003c!-- SPDX-License-Identifier: MIT --\u003e\n[![PyPi - Version](https://img.shields.io/pypi/v/odxtools)](https://pypi.org/project/odxtools)\n[![PyPI - License](https://img.shields.io/pypi/l/odxtools)](LICENSE)\n[![CI Status](https://github.com/mercedes-benz/odxtools/actions/workflows/tests.yml/badge.svg?branch=main)](https://github.com/mercedes-benz/odxtools/actions?query=branch%3Amain)\n\n# odxtools\n\n`odxtools` is a set of utilities for working with diagnostic\ndescriptions of automotive electronic control units using the data\nmodel and the associated technologies of the ODX standard.\n\n[ODX](https://de.wikipedia.org/wiki/ODX) stands for \"Open Diagnostic\ndata eXchange\" and is primarily an XML based file format to describe\nthe diagnostic capabilities of the electronic control units (ECUs) of\ncomplex distributed technical systems (usually cars and trucks). ODX\nis an [open standard maintained by ASAM\ne.V.](https://www.asam.net/standards/detail/mcd-2-d/) and is also\nstandardized internationally by\n[ISO-22901](https://www.iso.org/standard/41207.html).\n\nUsually, ODX is used to complement the\n[UDS](https://en.wikipedia.org/wiki/Unified_Diagnostic_Services)\nautomotive diagnostics standard -- which itself can be considered to\nbe an extension of\n[OBD-II](https://en.wikipedia.org/wiki/On-board_diagnostics#OBD-II) --\nto provide a machine-processable description of the vendor-specific\ndiagnostics functionality of a vehicle's ECUs. That said, the\nfunctionality which is described by ODX files neither needs to be a\nsuper- nor a subset of OBD-II/UDS, e.g., ODX can be used to describe\ndiagnostic functionality that uses fundamentally different wire\nformats and conventions than the ones mandated by OBD-II/UDS. (In\npractice, the ODX-described functionality usually adheres to these\nstandards, though.)\n\nThe functionality provided by `odxtools` encompasses parsing and\ninternalizing ODX diagnostic database files as well as de- and\nencoding the data of diagnostic requests and their responses\nsend to/received from ECUs in an pythonic manner.\n\n## Table of Contents\n\n- [Use Cases](#use-cases)\n- [Installation](#installation)\n- [Usage Examples](#usage-examples)\n  - [Python snippets](#python-snippets)\n- [Using the non-strict mode](#using-the-non-strict-mode)\n- [Interactive Usage](#interactive-usage)\n  - [Python REPL](#python-repl)\n- [Command line usage](#command-line-usage)\n  - [Generic parameters](#generic-parameters)\n  - [The `list` subcommand](#the-list-subcommand)\n  - [The `browse` subcommand](#the-browse-subcommand)\n  - [The `snoop` subcommand](#the-snoop-subcommand)\n  - [The `find` subcommand](#the-find-subcommand)\n  - [The `decode` subcommand](#the-decode-subcommand)\n  - [The `compare` subcommand](#the-compare-subcommand)\n- [Testing](#testing)\n- [Contributing](#contributing)\n- [Code of Conduct](#code-of-conduct)\n- [Provider Information](#provider-information)\n- [Acknowledgements](#acknowledgements)\n- [License](#license)\n\n## Use Cases\n\nHere are some of the intended use cases of `odxtools`:\n\n- Prototype development: Interacting with the diagnostic services of\n  electronic control units directly from python (requires taping into\n  the car's relevant CAN or ethernet bus)\n- End-of-production calibration/quality control: Initial set up and\n  running a self diagnosis of newly produced cars to ensure that\n  everything works as specified\n- After-sales: Implementing servicing functionality for workshops, i.e.,\n  defining test schedules based on the legally mandated functionality of\n  ISO 15031-6 (OBD II) as well as manufacturer-specific routines\n- Prototype development (II): Analyzing and debugging diagnostic sessions\n  done using third-party software\n- Prototype development (III): Implementing bridges to higher-level protocols\n  such as HTTP\n- Development for mass production: Accelerating the implementation of\n  diagnostic servicesfor low-cost ECUs by using `odxtools`-based code\n  generators for the diagnostic glue code on system-level languages like\n  C++ or rust\n\nPlease be aware that some of the use cases listed above are currently\nrather aspirational.\n\n## Installation\n\nThe easiest way of installing `odxtools` on your system is via `pip`:\n\n```bash\npython3 -m pip install odxtools\n```\n\nIf you want to develop `odxtools` itself, you need to install it from\nsource using `git`. The first step is to clone the repository:\n\n```bash\ncd $BASE_DIR\ngit clone https://github.com/mercedes-benz/odxtools\n```\n\nAfter this, make sure that all python dependencies are installed:\n\n```bash\ncd $BASE_DIR/odxtools\npython3 -m pip install -e .\n```\n\nNext, you can optionally build a package and install it on the system:\n\n```bash\ncd $BASE_DIR/odxtools\npython3 -m pip install --upgrade build\npython3 -m build\nsudo python3 -m pip install dist/odxtools-*.whl\n```\n\nFinally, update the `PYTHONPATH` environment variable and the newly\ncloned module is ready to be used:\n\n```bash\nexport PYTHONPATH=\"$BASE_DIR/odxtools:$PYTHONPATH\"\n```\n\nNow, you can check whether the installation worked:\n\n```bash\npython3 -m odxtools list -a \"$YOUR_PDX_FILE\"\n```\n\n## Usage Examples\n\n### Python snippets\n\n- Load an ODX database from file `somersault.pdx`:\n\n  ```python\n  import odxtools\n\n  db = odxtools.load_pdx_file(\"somersault.pdx\")\n  ```\n\n- List the names of all available services of the `somersault_lazy` ECU:\n\n  ```python\n  # [...]\n\n  ecu = db.ecus.somersault_lazy\n  print(f\"Available services for {ecu.short_name}: {ecu.services}\")\n  ```\n\n- Determine the CAN IDs which the `somersault_lazy` ECU uses to send\n  and receive diagnostic messages:\n\n  ```python\n  # [...]\n\n  print(f\"ECU {ecu.short_name} listens for requests on CAN ID 0x{ecu.get_can_receive_id():x}\")\n  print(f\"ECU {ecu.short_name} transmits responses on CAN ID 0x{ecu.get_can_send_id():x}\")\n  ```\n\n- Encode a `session_start` request to the `somersault_lazy` ECU:\n\n  ```python\n  # [...]\n\n  raw_request_data = ecu.services.session_start()\n\n  print(f\"Message for session start request of ECU {ecu.short_name}: {raw_request_data}\")\n  # -\u003e bytearray(b'\\x10\\x00')\n  ```\n\n- Print all mutable parameters of the `session_start` service's first\n  positive response:\n\n  ```python\n  # [...]\n\n  ecu.services.session_start.positive_responses[0].print_free_parameters_info()\n  ```\n\n- Encode the positive response to the `start_session` request:\n\n  ```python\n  # [...]\n\n  raw_request_data = ecu.services.session_start()\n  raw_response_data = ecu.services.session_start.positive_responses[0].encode(can_do_backward_flips=\"true\", coded_request=raw_request_data)\n\n  print(f\"Positive response to session_start() of ECU {ecu.short_name}: {raw_response_data.hex(' ')}\")\n  # -\u003e Positive response to session_start() of ECU somersault_lazy: 50 01\n  ```\n\n- Decode a request:\n\n  ```python\n  # [...]\n\n  raw_data = b\"\\x10\\x00\"\n  decoded_message = ecu.decode(raw_data)\n  for x in decoded_message:\n    print(f\"decoded as '{x.coding_object.short_name}': {x.param_dict}\")\n  # -\u003e decoded as 'start_session': {'sid': 16, 'id': 0}\n  ```\n\n- Decode a response to a request:\n\n  ```python\n  # [...]\n\n  raw_request_data = bytes.fromhex(\"1000\")\n  raw_response_data = bytes.fromhex(\"5001\")\n  decoded_response = ecu.decode_response(raw_response_data, raw_request_data)\n  for x in decoded_response:\n    print(f\"decoded as '{x.coding_object.short_name}': {x.param_dict}\")\n  # -\u003e decoded as 'session': {'sid': 80, 'can_do_backward_flips': 'true'}\n  ```\n\n## Using the non-strict mode\n\nBy default, odxtools raises exceptions if it suspects that it cannot\nfulfill a requested operation correctly. For example, if the dataset\nit is instructed to load is detected to be not conformant with the ODX\nspecification, or if completing the operation requires missing\nfeatures of odxtools. To be able to deal with such cases, odxtools\nprovides a \"non-strict\" mode where such issues are ignored, but where\nthe results are undefined. The following snippet shows how to instruct\nodxtools to load a non-conforming file in non-strict mode, and after\nthis is done, enables the safety checks again:\n\n  ```python\n  import odxtools\n\n  [...]\n\n  odxtools.exceptions.strict_mode = False\n  botched_db = odxtools.load_file(\"my_non-conforming_database.pdx\")\n  odxtools.exceptions.strict_mode = True\n\n  [...]\n  ```\n\n## Interactive Usage\n\n### Python REPL\n\npython's interactive read-reval-print-loop (REPL) supports\ntab-completion on most plattforms, i.e., in this case, all data can be\nconveniently interactivly discovered and this makes `odxtools` a very\nconvenient tool to explore the capabilities of a given ECU.\n\nA notable exception is the Microsoft Windows platform: Most python\ndistribtions for Windows do not enable tab-completion by default in\ntheir REPL.  For more convenience in such a scenario, we recommend\nusing\n[ptpython](https://github.com/prompt-toolkit/ptpython/). `ptpython`\ncan be installed like any other python package, i.e., via `python3 -m\npip install ptpython`. Then, the REPL ought to be started using\n\n```cmd\nc:\\odxtest\u003epython3 \"C:\\Python39\\Lib\\site-packages\\ptpython\\entry_points\\run_ptpython.py\"\n```\n\nAlternatively, `pyreadline` can be used after installing it via\n`python3 -m pip install pyreadline`.  With this, *basic*\ntab-completion for python under Windows in [Interactive\nMode](https://docs.python.org/3/tutorial/interpreter.html#interactive-mode)\nshould work.\n\n## Command line usage\n\nBased the python module, `odxtools` also provides a set of command\nline utilities for quick interactive explorations. Amongst others,\nthese utilities allow the inspection ODX/PDX files, snooping on\ndiagnostic sessions, etc. If `odxtools` is installed on a system-wide\nbasis, these commands can be invoked using `odxtools SUBCOMMAND\n[PARAMS]`, if the repository has been manually cloned via `git` and\n`odxtools` has not been installed on a system-wide basis, the way to\ninvoke these utilities is via `python3 -m odxtools SUBCOMMAND\n[PARAMS]`.\n\n### Generic parameters\n\nAvailable generic parameters and a list of subcommands can be obtained\nusing `odxtools --help`:\n\n```bash\n$ odxtools --help\nusage: odxtools [-h] [--version] {list,browse,snoop,find,decode,compare} ...\n\nUtilities to interact with automotive diagnostic descriptions based on the ODX standard.\n\nExamples:\n  For printing all services use:\n   odxtools list ./path/to/database.pdx --services\n  For browsing the data base and encoding messages use:\n   odxtools browse ./path/to/database.pdx\n\npositional arguments:\n  {list,browse,snoop,find,decode,compare}\n                        Select a sub command\n    list                Print a summary of automotive diagnostic files.\n    browse              Interactively browse the content of automotive diagnostic files.\n    snoop               Live decoding of a diagnostic session.\n    find                Find \u0026 display services by their name\n    decode              Find \u0026 print service by hex-data. Can also decode the hex-data to its named parameters.\n    compare              Compares two versions of diagnostic layers and/or databases with each other. Checks whether diagnostic services and its parameters have changed.\n\noptional arguments:\n  -h, --help            show this help message and exit\n  --version             Print the odxtools version\n```\n\nAll subcommands accept the `--help` parameter:\n\n```bash\n$ odxtools list --help\nusage: odxtools list [-h] [-v VARIANT [VARIANT ...]] [-g] [-s [SERVICE [SERVICE ...]]] [-p] [-d] [-a] PDX_FILE\n[...]\n```\n\nThe following is an incomplete list of the subcommands that are\ncurrently available:\n\n### The `list` subcommand\n\nThe `list` subcommand is used to parse a `.pdx` database file and\nprint the relevant parts of its content to the terminal.\n\n```bash\n$ odxtools list -h\nusage: odxtools list [-h] [-v VARIANT [VARIANT ...]] [-g] [-s [SERVICE [SERVICE ...]]] [-p] [-d] [-a] [--dump-database] PDX_FILE\n\nList the content of automotive diagnostic files (*.pdx)\n\nExamples:\n  For displaying only the names of the diagnostic layers use:\n    odxtools list ./path/to/database.pdx\n  For displaying all content use:\n    odxtools list ./path/to/database.pdx --all\n  For more information use:\n    odxtools list -h\n\npositional arguments:\n  PDX_FILE              path to the .pdx file\n\noptional arguments:\n  -h, --help            show this help message and exit\n  -v VARIANT [VARIANT ...], --variants VARIANT [VARIANT ...]\n                        Specifies which variants should be included.\n  -g, --global-negative-responses\n                        Print a list of the global negative responses for the selected ECUs.\n  -s [SERVICE [SERVICE ...]], --services [SERVICE [SERVICE ...]]\n                        Print a list of diagnostic services specified in the pdx.\n                        If no service names are specified, all services are printed.\n  -p, --params          Print a list of all parameters relevant for the selected items.\n  -d, --dops            Print a list of all data object properties relevant for the selected items\n  -a, --all             Print a list of all diagnostic services and DOPs specified in the pdx\n  --dump-database\n                        Ignore all other parameters and print a comprehensive dump of the full database instead of providing a pretty-printed summary\n```\n\nThe options `--variants` and `--services` can be used to specify which services should be printed.  \nIf the `--params` option is specified, the message layout and information about the service parameters (request as well as responses) are printed for all specified variants/services.\nIf the `--global-negative-responses` option is specified, all global negative responses are printed for all specified variants.\nIf the `--dops` option is specified, a list of all data object properties (their names) is printed for all specified variants/services.\nWith the parameter `--all` all data of the file that is recognized by `odxtools` is printed.\nThe default output does not display all information of the specified objects but a selection. To see all object information without formating choose the parameter `--dump-database`.\n\nExample:\n\n```bash\n$ odxtools list $BASE_DIR/odxtools/examples/somersault.pdx --variants somersault_lazy --services do_forward_flips --params\n\nOverview of diagnostic layers:\n┏━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓\n┃ Name            ┃ Variant Type ┃ Number of Services ┃ Number of DOPs ┃ Number of communication parameters ┃\n┡━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩\n│ somersault_lazy │ ECU-VARIANT  │                  6 │             12 │                                 10 │\n└─────────────────┴──────────────┴────────────────────┴────────────────┴────────────────────────────────────┘\n\nDiagnostic layer: 'somersault_lazy'\n Variant Type: ECU-VARIANT\n  CAN receive ID for protocol 'somersault_protocol': 0x7b\n  CAN send ID for protocol 'somersault_protocol': 0x1c8\n Description: Sloppy variant of the somersault ECU (lazy \u003c assiduous)\n\nThe services of 'somersault_lazy' are:\n\n Service 'do_forward_flips':\n  Description: Do a forward flip.\n\n  Request and response parameters of diagnostic service 'do_forward_flips'\n\n   Request 'do_forward_flips':\n    Identifying Prefix: 0xBA (b'\\xba')\n    Parameters:\n    ┏━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━━┳━━━━━━━━━━━━━━━━┳━━━━━━━━━━━┳━━━━━━━┳━━━━━━━━━━━━━━━━━┓\n    ┃ Name                    ┃ Byte Position ┃ Bit Length ┃ Semantic ┃ Parameter Type ┃ Data Type ┃ Value ┃ Linked DOP      ┃\n    ┡━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━╇━━━━━━━━━━━━╇━━━━━━━━━━╇━━━━━━━━━━━━━━━━╇━━━━━━━━━━━╇━━━━━━━╇━━━━━━━━━━━━━━━━━┩\n    │ sid                     │             0 │          8 │          │ CODED-CONST    │ A_UINT32  │ 0xBA  │                 │\n    ├─────────────────────────┼───────────────┼────────────┼──────────┼────────────────┼───────────┼───────┼─────────────────┤\n    │ forward_soberness_check │             1 │          8 │          │ VALUE          │ A_UINT32  │       │ soberness_check │\n    ├─────────────────────────┼───────────────┼────────────┼──────────┼────────────────┼───────────┼───────┼─────────────────┤\n    │ num_flips               │             2 │          8 │          │ VALUE          │ A_UINT32  │       │ num_flips       │\n    └─────────────────────────┴───────────────┴────────────┴──────────┴────────────────┴───────────┴───────┴─────────────────┘\n\n   Positive Response 'grudging_forward':\n    Parameters:\n    ┏━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━┳━━━━━━━┳━━━━━━━━━━━━┓\n    ┃ Name           ┃ Byte Position ┃ Bit Length ┃ Semantic ┃ Parameter Type         ┃ Data Type ┃ Value ┃ Linked DOP ┃\n    ┡━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━╇━━━━━━━━━━━━╇━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━╇━━━━━━━╇━━━━━━━━━━━━┩\n    │ sid            │             0 │          8 │          │ CODED-CONST            │ A_UINT32  │ 0xFA  │            │\n    ├────────────────┼───────────────┼────────────┼──────────┼────────────────────────┼───────────┼───────┼────────────┤\n    │ num_flips_done │             1 │          8 │          │ MATCHING-REQUEST-PARAM │           │       │            │\n    ├────────────────┼───────────────┼────────────┼──────────┼────────────────────────┼───────────┼───────┼────────────┤\n    │ sault_time     │             2 │          8 │          │ VALUE                  │ A_UINT32  │ 255   │ duration   │\n    └────────────────┴───────────────┴────────────┴──────────┴────────────────────────┴───────────┴───────┴────────────┘\n\n   Negative Response 'flips_not_done':\n    Parameters:\n    ┏━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━┳━━━━━━━━━━━┳━━━━━━━━━━━━┓\n    ┃ Name                    ┃ Byte Position ┃ Bit Length ┃ Semantic ┃ Parameter Type         ┃ Data Type ┃ Value     ┃ Linked DOP ┃\n    ┡━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━╇━━━━━━━━━━━━╇━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━╇━━━━━━━━━━━╇━━━━━━━━━━━━┩\n    │ sid                     │             0 │          8 │          │ CODED-CONST            │ A_UINT32  │ 0x7F      │            │\n    ├─────────────────────────┼───────────────┼────────────┼──────────┼────────────────────────┼───────────┼───────────┼────────────┤\n    │ rq_sid                  │             1 │          8 │          │ MATCHING-REQUEST-PARAM │           │           │            │\n    ├─────────────────────────┼───────────────┼────────────┼──────────┼────────────────────────┼───────────┼───────────┼────────────┤\n    │ reason                  │             2 │          8 │          │ NRC-CONST              │ A_UINT32  │ [0, 1, 2] │            │\n    ├─────────────────────────┼───────────────┼────────────┼──────────┼────────────────────────┼───────────┼───────────┼────────────┤\n    │ flips_successfully_done │             3 │          8 │          │ VALUE                  │ A_UINT32  │           │ num_flips  │\n    └─────────────────────────┴───────────────┴────────────┴──────────┴────────────────────────┴───────────┴───────────┴────────────┘\n```\n\n### The `browse` subcommand\n\nThe `browse` subcommand uses\n[InquirerPy](https://github.com/kazhala/InquirerPy) to interactively\nnavigate through the database of a `.pdx` file. For example, using the\n`browse` subcommand you can select the ECU and service without\nspamming the terminal:\n\n```bash\n$ odxtools browse $BASE_DIR/odxtools/examples/somersault.pdx\n? Select a Variant.  somersault_lazy\nECU-VARIANT 'somersault_lazy' (Receive ID: 0x7b, Send ID: 0x1c8)\n? The variant somersault_lazy offers the following services. Select one!  do_forward_flips\n? This service offers the following messages.  Request: do_forward_flips\n             7     6     5     4     3     2     1     0\n          +-----+-----+-----+-----+-----+-----+-----+-----+\n        0 | sid(8 bits)                                   |\n          +-----+-----+-----+-----+-----+-----+-----+-----+\n        1 | forward_soberness_check(8 bits)               |\n          +-----+-----+-----+-----+-----+-----+-----+-----+\n        2 | num_flips(8 bits)                             |\n          +-----+-----+-----+-----+-----+-----+-----+-----+\n     Parameter(short_name='sid', type='CODED-CONST', semantic=None, byte_position=0, bit_length=8, coded_value='0xba')\n     Parameter(short_name='forward_soberness_check', type='VALUE', semantic=None, byte_position=1, bit_length=8, dop_ref='somersault.DOP.soberness_check')\n      DataObjectProperty('soberness_check', category='LINEAR', internal_type='A_UINT32', physical_type='A_UINT32')\n     Parameter(short_name='num_flips', type='VALUE', semantic=None, byte_position=2, bit_length=8, dop_ref='somersault.DOP.num_flips')\n      DataObjectProperty('num_flips', category='LINEAR', internal_type='A_UINT32', physical_type='A_UINT32')\n[...]\n```\n\n### The `snoop` subcommand\n\nThe `snoop` subcommand can be used to decode a trace of a or a\ncurrently running diagnostic session.\n\n```bash\n$ odxtools snoop -h\nusage: odxtools snoop [-h] [--active] [--channel CHANNEL] [--rx RX] [--tx TX] [--variant VARIANT]\n                      [--protocol PROTOCOL]\n                      PDX_FILE\n\nLive decoding of a diagnostic session.\n\npositional arguments:\n  PDX_FILE              path to the .pdx file\n\noptions:\n  -h, --help            show this help message and exit\n  --active, -a          Active mode, sends flow control messages to receive ISO-TP telegrams successfully\n  --channel CHANNEL, -c CHANNEL\n                        CAN interface name to be used (required in active mode)\n  --rx RX, -r RX        CAN ID in which the ECU listens for diagnostic messages\n  --tx TX, -t TX        CAN ID in which the ECU sends replys to diagnostic messages  (required in active mode)\n  --variant VARIANT, -v VARIANT\n                        Name of the ECU variant which the decode process ought to be based on\n  --protocol PROTOCOL, -p PROTOCOL\n                        Name of the protocol used for decoding\n```\nExample:\n```bash\n# create a socketcan `vcan0` interface\nsudo ip link add dev vcan0 type vcan\nsudo ip link set vcan0 up\n\n# start the snooping on vcan0\nodxtools snoop -c vcan0 --variant \"somersault_lazy\" $BASE_DIR/odxtools/examples/somersault.pdx\n\n# on a different terminal, run the diagnostic session\n$BASE_DIR/odxtools/examples/somersaultlazy.py -c vcan0\n```\n\nThe snoop command will then output the following:\n\n```bash\n$ odxtools snoop -c vcan0 --variant \"somersault_lazy\" $BASE_DIR/odxtools/examples/somersault.pdx\nDecoding messages on channel vcan0\nTester: do_forward_flips(forward_soberness_check=18, num_flips=1)\n -\u003e 7fba7f (bytearray(b'\\x7f\\xba\\x7f'), 3 bytes)\nTester: start_session()\n -\u003e session()\nTester: do_forward_flips(forward_soberness_check=18, num_flips=1)\n -\u003e grudging_forward(num_flips_done=bytearray(b'\\x01'))\nTester: do_forward_flips(forward_soberness_check=35, num_flips=1)\n -\u003e flips_not_done(rq_sid=bytearray(b'\\xba'), reason=0, flips_successfully_done=0)\nTester: do_forward_flips(forward_soberness_check=18, num_flips=3)\n -\u003e grudging_forward(num_flips_done=bytearray(b'\\x03'))\nTester: do_forward_flips(forward_soberness_check=18, num_flips=50)\n -\u003e flips_not_done(rq_sid=bytearray(b'\\xba'), reason=1, flips_successfully_done=6)\n```\n\n### The `find` subcommand\n\nThe `find` subcommand can be used to find a service and its associated information by a partial name via cli.\n\n```bash\n$ odxtools find -h\nusage: odxtools find [-h] [-v VARIANT] -s [SERVICES ...] [-V] [-ro] PDX_FILE\n\nFind \u0026 print services by name\n\nExamples:\n  For displaying the services associated with the partial name 'Reset':\n    odxtools find ./path/to/database.pdx -s \"Reset\"\n  For more information use:\n    odxtools find -h\n\npositional arguments:\n  PDX_FILE              Location of the .pdx file\n\noptions:\n  -h, --help            show this help message and exit\n  -v VARIANT, --variants VARIANT\n                        Specifies which ecu variants should be included.\n  -s [SERVICES ...], --service-names [SERVICES ...]\n                        Print a list of diagnostic services partially matching given service names\n  -V, --verbose         Show all service details\n  -ro, --relaxed-output\n                        Relax output formatting rules (allow unknown bitlengths for ascii representation)\n```\n\nExample: Find diagnostic services with the name `session_start`\n\n```bash\n$ odxtools find $BASE_DIR/odxtools/examples/somersault.pdx -s session_start\n\n=====================================\nsomersault_lazy, somersault_assiduous\n=====================================\n\n Service 'session_start':\n  Pre-Condition States: in_bed, in_bed\n  State Transitions: in_bed -\u003e on_street, in_bed -\u003e in_park, in_bed -\u003e on_street\n```\n\n### The `decode` subcommand\n\nThe `decode` subcommand can be used to decode hex-data to a service, and its associated\nparameters.\n\n```bash\n$ odxtools decode -h\nusage: odxtools decode [-h] [-v VARIANT] -d DATA [-D] PDX_FILE\n\nDecode request by hex-data\n\nExamples:\n  For displaying the service associated with the request 10 01 \u0026 decoding it:\n    odxtools decode ./path/to/database.pdx -D -d '10 01'\n  For displaying the service associated with the request 10 01, without decoding it:\n    odxtools decode ./path/to/database.pdx -d '10 01'\n  For more information use:\n    odxtools decode -h\n\npositional arguments:\n  PDX_FILE              Location of the .pdx file\n\noptions:\n  -h, --help            show this help message and exit\n  -v VARIANT, --variants VARIANT\n                        Specifies which ecu variants should be included.\n  -d DATA, --data DATA  Specify data of hex request\n  -D, --decode          Decode the given hex data\n```\n\nExample: Decode diagnostic services with the request `10 00 00`\n\n```bash\n$ odxtools decode $BASE_DIR/odxtools/examples/somersault.pdx -d '10 00 00'\nBinary data: 10 00 00\nDecoded by service 'session_start' (decoding ECUs: somersault_lazy, somersault_assiduous)\n```\n\nExample: Decode diagnostic services with the request `10 00 00`, and parameters\n\n```bash\n$ odxtools decode $BASE_DIR/odxtools/examples/somersault.pdx -d '10 00 00' -D\nBinary data: 10 00 00\nDecoded by service 'session_start' (decoding ECUs: somersault_lazy, somersault_assiduous)\nDecoded data:\n  sid=16 (0x10)\n  id=0 (0x0)\n  bribe=0 (0x0)\n```\n\n### The `compare` subcommand\n\nThe `compare` subcommand can be used to compare databases (pdx-files) and diagnostic layers with each other. All diagnostic services as well as its parameters of specified databases and variants are compared with each other and changes are displayed.\n\n#### database comparison:\n- new diagnostic layers\n- deleted diagnostic layers\n- diagnostic layer comparison\n\n#### diagnostic layer comparison:\n- new services\n- deleted services\n- renamed services\n- service parameter comparison\n\n#### service parameter comparison:\nfind changes in following properties:\n- Name\n- Byte Position\n- Bit Length\n- Semantic\n- Parameter Type\n- Value\n- Data Type\n- Linked DOPs (Data Object Properties)\n\n```bash\n$ odxtools compare -h\nusage: odxtools compare [-h] [-v VARIANT [VARIANT ...]] [-db DATABASE [DATABASE ...]] [-V] PDX_FILE\n\nCompares two ecu versions or databases with each other. Checks whether diagnostic services and its parameters have changed.\n\nExamples:\n  Comparison of two ecu versions:\n    odxtools compare ./path/to/database.pdx -v variant1 variant2\n  Comparison of two database versions:\n    odxtools compare ./path/to/database.pdx -db ./path/to/old-database.pdx\n  For more information use:\n    odxtools compare -h\n\npositional arguments:\n  PDX_FILE              Location of the .pdx file\n\noptions:\n  -h, --help            show this help message and exit\n  -v VARIANT [VARIANT ...], --variants VARIANT [VARIANT ...]\n                        Compare specified ecu variants to each other.\n  -db DATABASE [DATABASE ...], --database DATABASE [DATABASE ...]\n                        Compare specified database file(s) to database file of first input argument.\n  -V, --verbose         Show all variant and service details\n```\n\nExample: Compare the ecu variants `somersault_lazy` and `somersault_assiduous`\n\n```bash\n$ odxtools compare $BASE_DIR/odxtools/examples/somersault.pdx -v somersault_assiduous somersault_lazy\n\nChanges in diagnostic layer 'somersault_assiduous' (ECU-VARIANT)\n (compared to 'somersault_lazy' (ECU-VARIANT))\n\nChanged diagnostic services of diagnostic layer 'somersault_assiduous' (ECU-VARIANT):\n\n New services\n┏━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━┳━━━━━━━━━━━━━┓\n┃ Name                 ┃ Semantic ┃ Hex-Request ┃\n┡━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━╇━━━━━━━━━━━━━┩\n│ set_operation_params │ FUNCTION │ 0xBD        │\n├──────────────────────┼──────────┼─────────────┤\n│ do_backward_flips    │ FUNCTION │ 0xBB        │\n├──────────────────────┼──────────┼─────────────┤\n│ headstand            │          │ 0x03        │\n└──────────────────────┴──────────┴─────────────┘\n```\n\nExample: Compare two databases\n\n```bash\n$ odxtools compare $BASE_DIR/odxtools/examples/somersault_modified.pdx -db $BASE_DIR/odxtools/examples/somersault.pdx -nd\n\nChanges in file 'somersault_modified.pdx'\n (compared to 'somersault.pdx')\n\nNew diagnostic layers:\n somersault_young (ECU-VARIANT)\n\nChanged diagnostic layers:\n somersault_base_variant (BASE-VARIANT)\n somersault_lazy (ECU-VARIANT)\n somersault_assiduous (ECU-VARIANT)\n\nChanged diagnostic services of diagnostic layer 'somersault_base_variant' (BASE-VARIANT):\n\n Renamed services\n┏━━━━━━━━━━━━━━━┳━━━━━━━━━━┳━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━┓\n┃ Name          ┃ Semantic ┃ Hex-Request ┃ Old service name ┃\n┡━━━━━━━━━━━━━━━╇━━━━━━━━━━╇━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━┩\n│ start_session │ SESSION  │ 0x1000      │ session_start    │\n├───────────────┼──────────┼─────────────┼──────────────────┤\n│ stop_session  │ SESSION  │ 0x1001      │ session_stop     │\n└───────────────┴──────────┴─────────────┴──────────────────┘\n\n Services with parameter changes\n ┏━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓\n ┃ Name              ┃ Semantic      ┃ Hex-Request ┃ Changed Parameters                                                                ┃\n ┡━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩\n │ start_session     │ SESSION       │ 0x1000      │ Properties of 2. positive response parameter 'can_do_backward_flips' have changed │\n ├───────────────────┼───────────────┼─────────────┼───────────────────────────────────────────────────────────────────────────────────┤\n │ stop_session      │ SESSION       │ 0x1001      │ Properties of 2. positive response parameter 'can_do_backward_flips' have changed │\n ├───────────────────┼───────────────┼─────────────┼───────────────────────────────────────────────────────────────────────────────────┤\n │ tester_present    │ TESTERPRESENT │ 0x3E00      │ Properties of 2. positive response parameter 'status' have changed                │\n ├───────────────────┼───────────────┼─────────────┼───────────────────────────────────────────────────────────────────────────────────┤\n │ do_backward_flips │ FUNCTION      │ 0xBB        │ Properties of 2. positive response parameter 'num_flips_done' have changed        │\n └───────────────────┴───────────────┴─────────────┴───────────────────────────────────────────────────────────────────────────────────┘\n\n  Detailed changes of diagnostic service 'start_session'\n   Properties of 2. positive response parameter 'can_do_backward_flips' have changed:\n   ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━┓\n   ┃ Attribute                                        ┃ Old Value                ┃ New Value              ┃\n   ┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━┩\n   │ Linked DOP (data object property) object         │ \u003csomersault.DOP.boolean\u003e │ \u003csomersault.DOP.uint8\u003e │\n   ├──────────────────────────────────────────────────┼──────────────────────────┼────────────────────────┤\n   │ Linked DOP object: Name                          │ boolean                  │ uint8                  │\n   ├──────────────────────────────────────────────────┼──────────────────────────┼────────────────────────┤\n   │ Linked DOP object: Computation Method            │ \u003cCOMPU-METHOD\u003e           │ \u003cCOMPU-METHOD\u003e         │\n   ├──────────────────────────────────────────────────┼──────────────────────────┼────────────────────────┤\n   │ Linked DOP object: PHYSICAL-TYPE: Base data type │ A_UNICODE2STRING         │ A_UINT32               │\n   └──────────────────────────────────────────────────┴──────────────────────────┴────────────────────────┘\n\n[...]\n```\n\n## Testing\n\nThe included unit tests can be run via\n\n```bash\npython -m unittest tests/test_*.py\n```\n\nThe static type checker can be run via\n```bash\npython3 -m mypy --ignore-missing-imports odxtools\n```\n\n## Contributing\n\nWe welcome any contributions.  If you want to contribute to this\nproject, please read the [contributing guide](https://github.com/mercedes-benz/odxtools/blob/main/CONTRIBUTING.md).\n\n## Code of Conduct\n\nPlease read our [Code of Conduct](https://github.com/mercedes-benz/foss/blob/master/CODE_OF_CONDUCT.md)\nas it is our base for interaction.\n\n## Provider Information\n\nPlease visit \u003chttps://mbition.io/en/home/index.html\u003e for information on the provider.\n\nNotice: Before you use the program in productive use, please take all necessary precautions,\ne.g. testing and verifying the program with regard to your specific use.\nThe program was tested solely for our own use cases, which might differ from yours.\n\n## Acknowledgements\n\nThis work includes research of the project\n[SofDCar](https://sofdcar.de/) (19S21002), which is funded by the\n[German Federal Ministry for Economic Affairs and\nClimate Action](https://www.bmwk.de/).\n\n## License\n\nThis project is licensed under the [MIT LICENSE](LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmercedes-benz%2Fodxtools","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmercedes-benz%2Fodxtools","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmercedes-benz%2Fodxtools/lists"}