Skip to main content

Universal Calibration Protocol for Python

Project description

pyxcp_social.svg

Reliable Python tooling for the ASAM MCD-1 XCP protocol (measurement, calibration, flashing) with multiple transports (CAN, Ethernet, USB, Serial) and handy CLI utilities.

PyPI Python Versions License: LGPL v3+ Code style: black

pyXCP is a production-ready Python library for communicating with XCP-enabled devices, most commonly automotive ECUs. Use it to take measurements, adjust parameters (calibration), stream DAQ/STIM, and program devices during development.

Highlights:

  • Transports: Ethernet (TCP/IP), CAN, USB, Serial (SxI)

  • Cross-platform: Windows, Linux, macOS

  • Rich CLI tools for common XCP tasks

  • Extensible architecture and layered design


Installation

The easiest way is from PyPI:

pip install pyxcp

To install from the main branch:

pip install git+https://github.com/christoph2/pyxcp.git

Requirements

  • Python >= 3.10

  • Building from source requires a working C/C++ toolchain (native extensions are used for performance). Wheels are provided for common platforms and Python versions; if a wheel is not available, pip will build from source.

  • An XCP slave device (or simulator)

Quick start

The tutorial walks you through typical tasks end-to-end: see tutorial.

Minimal example using the built-in argument parser and context manager:

from pyxcp.cmdline import ArgumentParser

ap = ArgumentParser(description="pyXCP hello world")

with ap.run() as x:
    x.connect()
    identifier = x.identifier(0x01)
    print(f"ID: {identifier!r}")
    print(x.slaveProperties)
    x.disconnect()

Configuration

pyXCP supports a traitlets-based configuration system.

  • Recommended Python config example and generator: tutorial and configuration

  • Legacy TOML examples remain available for compatibility.

Command‑line tools

Installed entry points (see pyproject.toml):

  • xcp-info — print capabilities and properties

  • xcp-id-scanner — scan for slave identifiers

  • xcp-fetch-a2l — retrieve A2L from target (if supported)

  • xcp-profile — generate/convert config files

  • xcp-examples — launch assorted demos/examples

  • xmraw-converter — convert recorder .xmraw data

  • pyxcp-probe-can-drivers — list available CAN interfaces

Run any tool with -h for options.

Features

  • Multiple transport layers: Ethernet (TCP), CAN, USB, SxI (serial/UART)

  • High-precision IEEE 1588/PTP hardware timestamping (Ethernet/UDP on Windows and Linux)

  • Data Acquisition (DAQ) and Stimulation (STIM)

  • Calibration (read/write parameters)

  • Flashing/programming workflows

  • A2L (ASAM MCD‑2 MC) support

  • Recorder utilities and converters (see recorder)

  • Extensible architecture for custom transports

Documentation

To build the Sphinx documentation locally:

  1. Install doc requirements:

    pip install -r docs/requirements.txt

  2. Build:

    sphinx-build -b html docs docs/_build/html

  3. Open

    docs/_build/html/index.html

Compatibility

  • Operating systems: Windows, Linux, macOS

  • Python: 3.10 - 3.14, CPython wheels where available

  • CAN backends: python-can compatible drivers (see howto_can_driver)

Contributing

Contributions are welcome! Please: - Read CODE_OF_CONDUCT - Open an issue or discussion before large changes - Use pre-commit to run linters and tests locally

License

GNU Lesser General Public License v3 or later (LGPLv3+). See LICENSE for details.

References

About ASAM MCD‑1 XCP

XCP (Universal Measurement and Calibration Protocol) is an ASAM standard defining a vendor‑neutral protocol to access internal data of electronic control units (ECUs) for measurement, calibration (parameter tuning), and programming. XCP decouples the protocol from the physical transport, so the same command set can be carried over different buses such as CAN, FlexRay, Ethernet, USB, or Serial.

  • Roles: An XCP Master (this library) communicates with an XCP Slave (your device/ECU or simulator).

  • Layered concept: XCP defines an application layer and transport layers. pyXCP implements the application layer and multiple transport bindings.

  • Use cases:

    • Measurement: Read variables from the ECU in real‑time, including high‑rate DAQ streaming.

    • Calibration: Read/write parameters (calibration data) in RAM/flash.

    • Programming: Download new program/data to flash (where the slave supports it).

For the authoritative description, see the ASAM page: https://www.asam.net/standards/detail/mcd-1-xcp/

XCP in a nutshell

  • Connect/Session: The master establishes a connection, negotiates capabilities/features, and optionally unlocks protected functions via seed & key.

  • Addressing: Memory is accessed via absolute or segment‑relative addresses. Addressing modes are described in the associated A2L file (ASAM MCD‑2 MC), which maps symbolic names to addresses, data types, and conversion rules.

  • Events: The slave exposes events (e.g., “1 ms task”, “Combustion cycle”), which trigger DAQ sampling. The master assigns signals (ODTs) to these events for time‑aligned acquisition.

  • DAQ/STIM: DAQ = Data Acquisition (slave → master), STIM = Stimulation (master → slave). Both use event‑driven lists for deterministic timing.

  • Timestamps: DAQ may carry timestamps from the slave for precise time correlation.

  • Security: Access to sensitive commands (e.g., programming, calibration) can be protected by a seed & key algorithm negotiated at runtime.

  • Checksums: XCP defines checksum services useful for verifying memory regions (e.g., after flashing).

Relation to A2L (ASAM MCD‑2 MC)

While XCP defines the protocol, the A2L file describes the measurement and calibration objects (characteristics, measurements), data types, conversion rules, and memory layout. In practice, you use pyXCP together with an A2L to: - Resolve symbolic names to addresses and data types. - Configure DAQ lists from human‑readable signal names. - Interpret raw values using the appropriate conversion methods.

pyXCP provides utilities to fetch A2L data when supported by the slave and to work with A2L‑described objects. See also pya2ldb!

Transports and addressing

XCP is transport‑agnostic. pyXCP supports multiple transports and addressing schemes: - CAN (XCP on CAN): Robust and ubiquitous in vehicles; limited payload and bandwidth; suited for many calibration tasks and moderate DAQ rates. - Ethernet (XCP on TCP/UDP): High bandwidth with low latency; well suited for rich DAQ and programming workflows. - USB: High throughput for lab setups; requires device support. - Serial/SxI: Simple point‑to‑point links for embedded targets and simulators.

The exact capabilities (e.g., max CTO/DTO, checksum types, timestamping) are negotiated at connect time and depend on the slave and transport.

Supported features (overview)

The scope of features depends on the connected slave. At the library level, pyXCP provides: - Session management: CONNECT/DISCONNECT, GET_STATUS/SLAVE_PROPERTIES, communication mode setup, error handling. - Memory access: Upload/short upload, Download/Download Next, verifications, optional paged memory where supported. - DAQ/STIM: Configuration of DAQ lists/ODTs, event assignment, data streaming, timestamp handling when available. - Programming helpers: Building blocks for program/erase/write flows (exact sequence per slave’s flash algorithm and A2L description). - Security/Seed & Key: Pluggable seed‑to‑key resolution including 32↔64‑bit bridge on Windows. - Utilities: Identifier scanning, A2L helpers, recorder and converters.

Refer to tutorial and configuration for feature usage, and xcp-info for a capability dump of your target.

Compliance and versions

pyXCP aims to be compatible with commonly used parts of ASAM MCD‑1 XCP. Specific optional features are enabled when a slave advertises them during CONNECT. Because implementations vary across vendors and ECU projects, always consult your A2L and use xcp-info to confirm negotiated options (e.g., checksum type, timestamp unit, max DTO size, address granularity).

If you rely on a particular XCP feature/profile not mentioned here, please open an issue with details about your slave and A2L so we can clarify support and—if feasible—add coverage.

Safety, performance, and limitations

  • Safety‑critical systems: XCP is a development and testing protocol. Do not enable measurement/calibration on safety‑critical systems in the field unless your system‑level safety case covers it.

  • Performance: Achievable DAQ rates depend on transport bandwidth, ECU event rates, DTO sizes, and host processing. Ethernet typically yields the highest throughput.

  • Latency/jitter: Event scheduling in the slave and OS scheduling on the host can affect determinism. Use timestamps to correlate data precisely.

  • Access control: Seed & key protects sensitive functions; your organization’s policy should govern algorithm distribution and access.

Further resources

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyxcp-0.26.0.tar.gz (266.1 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

pyxcp-0.26.0-cp314-cp314-win_arm64.whl (3.3 MB view details)

Uploaded CPython 3.14Windows ARM64

pyxcp-0.26.0-cp314-cp314-win_amd64.whl (3.4 MB view details)

Uploaded CPython 3.14Windows x86-64

pyxcp-0.26.0-cp313-cp313-win_arm64.whl (2.6 MB view details)

Uploaded CPython 3.13Windows ARM64

pyxcp-0.26.0-cp313-cp313-win_amd64.whl (2.7 MB view details)

Uploaded CPython 3.13Windows x86-64

pyxcp-0.26.0-cp312-cp312-win_arm64.whl (2.1 MB view details)

Uploaded CPython 3.12Windows ARM64

pyxcp-0.26.0-cp312-cp312-win_amd64.whl (2.1 MB view details)

Uploaded CPython 3.12Windows x86-64

pyxcp-0.26.0-cp311-cp311-win_arm64.whl (1.5 MB view details)

Uploaded CPython 3.11Windows ARM64

pyxcp-0.26.0-cp311-cp311-win_amd64.whl (1.5 MB view details)

Uploaded CPython 3.11Windows x86-64

pyxcp-0.26.0-cp310-cp310-win_arm64.whl (896.3 kB view details)

Uploaded CPython 3.10Windows ARM64

pyxcp-0.26.0-cp310-cp310-win_amd64.whl (896.7 kB view details)

Uploaded CPython 3.10Windows x86-64

File details

Details for the file pyxcp-0.26.0.tar.gz.

File metadata

  • Download URL: pyxcp-0.26.0.tar.gz
  • Upload date:
  • Size: 266.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pyxcp-0.26.0.tar.gz
Algorithm Hash digest
SHA256 8941c8ef440896914fea779a358392b453caa769db34a58d56cc156f403d48ee
MD5 4ce4c2c15fe8cb4cd689dec596108c12
BLAKE2b-256 aa77f249d05425e36e132e3ed2cb0a7b1c9900bc900ac64b92a841a0ce36da21

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyxcp-0.26.0.tar.gz:

Publisher: pythonapp.yml on christoph2/pyxcp

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyxcp-0.26.0-cp314-cp314-win_arm64.whl.

File metadata

  • Download URL: pyxcp-0.26.0-cp314-cp314-win_arm64.whl
  • Upload date:
  • Size: 3.3 MB
  • Tags: CPython 3.14, Windows ARM64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pyxcp-0.26.0-cp314-cp314-win_arm64.whl
Algorithm Hash digest
SHA256 6f294bc4a01c7b9ae527be32ec5ff90f4b36a6f2fcb4424d1d57fb2bf46b70c5
MD5 73aef06cf3aaf97f8b0dc28f8ea9e788
BLAKE2b-256 187ba2a1f1bc5de01e398c338ee7e241097fcd7dec853827cff2e9e31a0c88df

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyxcp-0.26.0-cp314-cp314-win_arm64.whl:

Publisher: pythonapp.yml on christoph2/pyxcp

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyxcp-0.26.0-cp314-cp314-win_amd64.whl.

File metadata

  • Download URL: pyxcp-0.26.0-cp314-cp314-win_amd64.whl
  • Upload date:
  • Size: 3.4 MB
  • Tags: CPython 3.14, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pyxcp-0.26.0-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 34f94cdc23ecefc5c5468ef4cd9129a94118f05c3209aeb0d2e01f21a0b45057
MD5 33a75410090cfd9d743774bd19c47aee
BLAKE2b-256 ab129fb07787898f52a9c4162edee38aa1a4af5d25b66a2c33c8079d303edf12

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyxcp-0.26.0-cp314-cp314-win_amd64.whl:

Publisher: pythonapp.yml on christoph2/pyxcp

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyxcp-0.26.0-cp313-cp313-win_arm64.whl.

File metadata

  • Download URL: pyxcp-0.26.0-cp313-cp313-win_arm64.whl
  • Upload date:
  • Size: 2.6 MB
  • Tags: CPython 3.13, Windows ARM64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pyxcp-0.26.0-cp313-cp313-win_arm64.whl
Algorithm Hash digest
SHA256 e225f2f581f4fdcdf73e396948e73791e03831ec2025a1a121998d74b4a82f83
MD5 1fa460ceda3714bebf93d8026c1a715c
BLAKE2b-256 63d0bf51eadf51aa42112c04c4c46acc77749b454763e018d0ea531ac33ac998

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyxcp-0.26.0-cp313-cp313-win_arm64.whl:

Publisher: pythonapp.yml on christoph2/pyxcp

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyxcp-0.26.0-cp313-cp313-win_amd64.whl.

File metadata

  • Download URL: pyxcp-0.26.0-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 2.7 MB
  • Tags: CPython 3.13, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pyxcp-0.26.0-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 3d59d9629dcc4ac9768acbfc0a944e1513ba13078646a3767f8f330585dd1ee7
MD5 c2c0136974b1d5b30e7c755330ce4a28
BLAKE2b-256 2bc1c6dec3e4a313257cd47cec04d18c929627620df8f0adb847756af015265b

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyxcp-0.26.0-cp313-cp313-win_amd64.whl:

Publisher: pythonapp.yml on christoph2/pyxcp

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyxcp-0.26.0-cp312-cp312-win_arm64.whl.

File metadata

  • Download URL: pyxcp-0.26.0-cp312-cp312-win_arm64.whl
  • Upload date:
  • Size: 2.1 MB
  • Tags: CPython 3.12, Windows ARM64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pyxcp-0.26.0-cp312-cp312-win_arm64.whl
Algorithm Hash digest
SHA256 f2cad6210c5429282e5eb102ebd58d24e169c03b3c715f4cea709c97da08d0bb
MD5 67590e5db89304fb2e5ed0581c1ce665
BLAKE2b-256 61c6027eb140b0d0912f6e45033915107068a68dca852e7552696c24d775420c

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyxcp-0.26.0-cp312-cp312-win_arm64.whl:

Publisher: pythonapp.yml on christoph2/pyxcp

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyxcp-0.26.0-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: pyxcp-0.26.0-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 2.1 MB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pyxcp-0.26.0-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 5fa3f2bad7f805e29ec6c73020dae1b7c0134b92c2570490af582d3821e6375e
MD5 5b3332b824569b7d6baf6633e0ba13f4
BLAKE2b-256 2edca1c76c6e6fb8ab0542552183f5cd020a05c6c445ebd98b53b4f886262b37

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyxcp-0.26.0-cp312-cp312-win_amd64.whl:

Publisher: pythonapp.yml on christoph2/pyxcp

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyxcp-0.26.0-cp311-cp311-win_arm64.whl.

File metadata

  • Download URL: pyxcp-0.26.0-cp311-cp311-win_arm64.whl
  • Upload date:
  • Size: 1.5 MB
  • Tags: CPython 3.11, Windows ARM64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pyxcp-0.26.0-cp311-cp311-win_arm64.whl
Algorithm Hash digest
SHA256 2ef5b2cb43f7c50e77d208d0718f4e8edd4b7d7cbfcda4bdc8b94275ac31669f
MD5 48a1fab92ab56c8d08d39f6ba8cfc554
BLAKE2b-256 b38be5d9943fc14bcc40ac040eab87e65b66a922c1bab95f96e8a64c0a333df7

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyxcp-0.26.0-cp311-cp311-win_arm64.whl:

Publisher: pythonapp.yml on christoph2/pyxcp

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyxcp-0.26.0-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: pyxcp-0.26.0-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 1.5 MB
  • Tags: CPython 3.11, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pyxcp-0.26.0-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 9b625c723a563b0a9b629d37898a25974643a2beae21011b1ddccaf1ef901a67
MD5 f0c0531b2533f6ce6ae1c15e782a9388
BLAKE2b-256 511058a504698d9c9dbc4828c1e1b20862bac4501da75ea7cd14d86c6e26b8b2

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyxcp-0.26.0-cp311-cp311-win_amd64.whl:

Publisher: pythonapp.yml on christoph2/pyxcp

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyxcp-0.26.0-cp310-cp310-win_arm64.whl.

File metadata

  • Download URL: pyxcp-0.26.0-cp310-cp310-win_arm64.whl
  • Upload date:
  • Size: 896.3 kB
  • Tags: CPython 3.10, Windows ARM64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pyxcp-0.26.0-cp310-cp310-win_arm64.whl
Algorithm Hash digest
SHA256 282ad63c6231484715f945bbcae0a433189e3c3460c37cfec69e8800736c3531
MD5 5b7a58b128be94e2e55e8249c18c1d66
BLAKE2b-256 2a9e5d9a4b04fa51884133023a3f0fb56d768dcbd349eb70df2dbbcb60c182ea

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyxcp-0.26.0-cp310-cp310-win_arm64.whl:

Publisher: pythonapp.yml on christoph2/pyxcp

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyxcp-0.26.0-cp310-cp310-win_amd64.whl.

File metadata

  • Download URL: pyxcp-0.26.0-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 896.7 kB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pyxcp-0.26.0-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 89fb482c4030f4da1c83050eee7560ed8aeedc846d95b8d344f70e45b08e9e33
MD5 729bb6480e83fde0e851f951475ba3e6
BLAKE2b-256 341613a827357944f3353372be68bf3205a839b45d1c18dbd661196f5de4a561

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyxcp-0.26.0-cp310-cp310-win_amd64.whl:

Publisher: pythonapp.yml on christoph2/pyxcp

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page