vectorgrp / XCPlite

Simple implementation of the ASAM XCP on Ethernet protocol
MIT License
163 stars 88 forks source link
a2l asam asap autosar autosar-adaptive calibration-tool can-bus canape canoe mcd mdf vector-informatik xcp

XCPlite V6

Copyright 2024 Vector Informatik GmbH

XCPlite is a lightweight demo implementation of the ASAM XCP V1.4 standard protocol for measurement and calibration of electronic control units. The demo implementation uses Ethernet UDP or TCP communication on POSIX based or Windows Operating Systems. XCPlite is provided to test and demonstrate calibration tools such as CANape or any other XCP client implementation. It demonstrates some capabilities of XCP and may serve as a base for individually customized implementations.

New to XCP? Checkout Vector�s XCP Reference Book here: https://www.vector.com/int/en/know-how/protocols/xcp-measurement-and-calibration-protocol/xcp-book# or visit the Virtual VectorAcedemy for an E-Learning on XCP: https://elearning.vector.com/

A list of restrictions compared to Vectors free XCPbasic or commercial XCPprof may be found in the source file xcpLite.c. XCPbasic is an implementation optimized for smaller Microcontrollers and CAN as Transport-Layer. XCPprof is a product in Vectors AUTOSAR MICROSAR and CANbedded product portfolio.

XCPlite

XCPlite has been testet on CANFD, there is some experimental code included, but there is no example target to showcase this. XCPlite is not recomended for CAN.

No manual A2L creation (ASAP2 ECU description) is required for XCPlite. An A2L with a reduced featureset may be generated through code instrumentation during runtime and can be automatically uploaded by XCP.

Included code examples (Build Targets):

XCPlite: Getting started with a simple demo in C with minimum code and features. Shows the basics how to integrate XCP in existing applications. Compiles as C.

C_DEMO: Shows more sophisticated calibration, maps and curves, calibration page switching and EPK check. Compiles as C or C++.

CPP_Demo: XCP server as a C++ singleton. Demonstrates an approach how to calibrate and measure members of dynamic instances of classes.

Code instrumentation for measurement events:

Very simple code instrumentation needed for event triggering and data copy, event definition and data object definition.

Example:

Definition:

Define a global variable which should be acquired and visualized in realtime by the measurement and calibration tool

  double channel1; 

A2L generation:

A2L is an ASCII file format (ASAM standard) to describe ECU internal measurement and calibration values. With XCPlite, the A2L file may be generated during runtime at startup of the application:

  A2lCreateEvent("ECU"); // Create a new event with name "ECU""
  A2lSetEvent("ECU"); // Set event "ECU" to be associated to following measurement value definitions
  A2lCreatePhysMeasurement(channel1, 2.0, 1.0, "Volt", "Demo floating point signal"); // Create a measurement signal "channel1" with linear conversion rule (factor,offset) and unit "Volt"

Measurement data acquisition event:

A measurement event is a trigger for measurement data acquisition somewhere in the code. Multiples measurement objects such as channel1, even complexer objects like structs and instances can be associated to the event. This is done during runtime in the GUI of the measurement and calibration tool. An event will be precicly timestamped with ns resolution, timestamps may obtained from PTP synchronized clocks and the data attached to it, is garantueed to be consistent. The blocking duration of the XcpEvent function is as low as possible:

  channel1 += 0.6;
  XcpEvent(1); // Trigger event number 1, attach a timestamp and copy measurement data

This is a screenshot of the tool GUI.

CANape

Configuration options:

All settings and parameters for the XCP protocol and transport layer are located in xcp_cfg.h and xcptl_cfg.h. Compile options for the different demo targets are located in main_cfg.h.

Notes:

Version History

Version 6.x:

Version 5.x:

Version 4.x:

Build

Linux or macOS

Install development tooling

for Linux:

sudo apt-get install cmake g++ clang ninja-build

for MacOS

brew install cmake gcc 

Build

Edit CMakeLists.txt: set(WINDOWS FALSE), set(MACOS FALSE)

cd <targetDirectory> (XCPlite or CPP_Demo or C_DEMO)
cmake -DCMAKE_BUILD_TYPE=Release -S . -B build  
cd build
make
./<targetName>.out (XCPlite or CPP_Demo or C_DEMO)

Windows x86_64

Use the Visual Studio 19 projects included in the repo or build projects with CMake.

Build Visual Studio project and solution

Start cmake-gui Start the generated VS solution

Build on Windows command line

For the CMake setup, prepare your command line environment. Set compiler to Microsoft x64 cl.exe and make sure the system finds cmake and ninja or make. You can also use the Windows clang compiler.

call "C:\Program Files (x86)\Microsoft Visual Studio 15.0\VC\Auxiliary\Build\vcvars64.bat"
set PATH=C:\Tools\ninja;%PATH%
set PATH=C:\Tools\cmake_3.17.2.0\bin;%PATH%
cd XCPlite
mkdir build_release
cd build_release
cmake -GNinja -DCMAKE_BUILD_TYPE=Release ../C_Demo
ninja