Introduction

XCP-Ray measures and calibrates ECUs over XCP: it reads signals cyclically (DAQ), shows them in scopes and value displays, records them, and writes parameters, curves and maps into the ECU. CAN buses described by a DBC file can be decoded and recorded at the same time.

XCP-Ray is in its public beta: every feature is free, also for commercial use. It will stay free for makers, students, teaching and personal use; some features for professional use may need a paid license in the future. A version you have downloaded keeps working under the license it came with (LICENSE.txt).

What XCP-Ray can do

The programs

ProgramPurpose
xcpray-guithe measurement and calibration tool (this manual, chapters 2 to 6)
xcpray-climeasuring and calibration on the command line, also for scripts (JSON output)
xcp-sima simulated ECU (XCP on CAN, UDP/IP, TCP/IP or serial), also sends DBC test patterns
x1-recinspects, packs and exports recordings
x1-a2linspects A2L files
x1-dbcshows and decodes DBC files
x1-elf2a2lcreates or updates an A2L file from an ELF file (DWARF) and a short variable list
x1-a2l-studioA2L from and with an ELF file in a window: update addresses, conversion rules, edit every entry
x1-candump, x1-cansendSocketCAN helpers (Linux only)

All programs print their options with --help and their version with --version.

Getting started

Quick start without hardware

The simulator xcp-sim behaves like a small ECU: counters, sine, ramp, square, temperature, noise, a curve and a map, and parameters that drive them. It writes a matching A2L file.

On Windows, double-click start-demo.bat in the package: it starts the simulator (XCP on UDP/IP, only on this computer) and opens the demo project. Then choose Measurement > Start (F5).

On Linux, create a virtual CAN interface once after every reboot and start the demo:

sudo modprobe vcan
sudo ip link add dev vcan0 type vcan
sudo ip link set vcan0 mtu 72 up
cd examples
../bin/xcp-sim vcan0 --dbc vehicle.dbc &
../bin/xcpray-gui -P can_demo.x1p

Then Measurement > Start (F5). Change the amplitude or the frequency in the value display and watch the scope.

The same on CAN FD (up to 64 bytes per frame): start the simulator with --fd --max-cto 64 and open can_fd_demo.x1p. Its ECU takes CAN FD from the A2L (the simulator writes a CAN_FD block), its bus is set to CAN FD; Devices > ECUs and buses shows both settings.

../bin/xcp-sim vcan0 --fd --max-cto 64 --dbc vehicle.dbc &
../bin/xcpray-gui -P can_fd_demo.x1p

Connecting a real ECU

  1. Devices > Add ECU.
  2. Choose the A2L file of the ECU (the ... button opens the file browser).
  3. Choose the transport and its settings (see "ECUs and buses").
  4. Click Add. XCP-Ray connects at once and shows the ECU in the signal browser.
  5. Drag signals from the signal browser into a display, then Measurement > Start (F5).

Values not given in the dialog (CAN-IDs, bitrate, UDP host and port, baud rate) come from the A2L file (IF_DATA XCP).

When the A2L has an EPK (MOD_PAR with EPK and ADDR_EPK), XCP-Ray reads the EPK of the ECU after every connect and compares it: a different EPK means the A2L probably belongs to another software version; the log shows a warning with both values, the connection stays.

Updating the A2L with A2L Studio

When the firmware was built anew, its addresses may have moved. While no measurement runs, "A2L Studio" in Devices > ECUs and buses (or Devices > Open A2L in A2L Studio) starts x1-a2l-studio with the A2L of the ECU; there load the ELF file and click "Update A2L".

XCP-Ray notices when the A2L file of an ECU changes (by A2L Studio or, for example, by the build of a kit) and asks after the measurement: Reload sets the ECU up again with the new file and connects again if it was connected; the displays keep their signals. Not now keeps the loaded file.

Errors in the A2L file

A newly chosen A2L file is checked at once. If it has errors, a dialog lists every faulty block with its line, type (e.g. MEASUREMENT), name and problem: an unknown data type, a missing value, a reference to a COMPU_METHOD, COMPU_TAB, RECORD_LAYOUT or AXIS_PTS that does not exist, or a name defined twice.

If the file cannot be read at all (e.g. a missing /end), the dialog shows the line of the error and only offers another file. When a project is opened, left-out blocks are listed in the log.

A2L files that include other files (/include objects.a2l, relative to the including file) are read with them; the line of an error then names the included file as well (objects.a2l:812). An included file that does not exist is listed as a problem and left out; often these are A2ML files that do not come with the A2L and are not needed. A change of an included file also offers Reload.

Structures in the A2L (A2L 1.7)

Newer A2L files describe structures once as a type (TYPEDEF_STRUCTURE, TYPEDEF_MEASUREMENT, TYPEDEF_CHARACTERISTIC, TYPEDEF_AXIS) and place them with INSTANCE, for example the files XCPlite makes. XCP-Ray shows every element as a signal or parameter of its own: params.amplitude for the component amplitude of the instance params, stats[2].count for an element of an array of structures. A curve whose axis is a component of the same structure (THIS.axis) uses the axis of its own instance. An instance of an unknown type, or a pointer, is listed as a problem and left out; a single unknown component leaves out only that component.

Arrays of parameters (VAL_BLK) with one or two dimensions open in the curve and map editors, with the element index as axis; the axis can not be moved. Their elements are also parameters of their own, levels[2] or table[1][3]: in the signal browser under a node below the array, to read and change single values in a value display (also +/-), like any scalar parameter.

Text parameters (ASCII, e.g. a variant code or a name) show their text in a value display; type a new text and press Enter. It may have as many bytes as the A2L gives (an umlaut counts two); the rest of the memory is filled with zero bytes.

Arrays of measurements (MATRIX_DIM or ARRAY_SIZE) are measured element by element: every element is a measurement of its own, cells[0] to cells[111], and with two dimensions matrix[row][column] (the last index runs fastest in memory, as in C). In the signal browser the array is a node that opens to its elements; drag the node into a scope, value or bar display to add all elements, or pick single elements. They are measured by DAQ like any measurement, with the event, conversion and limits of the array, recorded and exported under their element names. The array itself is not a signal: asking for cells without an index says which elements exist. Arrays with more than 65535 elements are not listed, but their elements can be typed by name. In narrow columns (value and bar displays) a long element name is shortened in the middle so that the index stays visible: bms_cell_vo..[57].

Linux: rights for CAN

XCP-Ray sets the bitrate of a CAN interface itself. That needs the right CAP_NET_ADMIN. Grant it once (XCP-Ray never runs sudo itself; when the right is missing it shows this command with the full path):

sudo setcap cap_net_admin+ep bin/xcpray-gui bin/xcpray-cli

Serial ports (/dev/ttyUSB0, /dev/ttyACM0) need membership in the group dialout on most distributions: sudo usermod -aG dialout $USER, then log in again.

Linux: LIN with PEAK

LIN goes through the LIN driver of PEAK (not SocketCAN). Download it from www.peak-system.com/quick/PLIN-Linux-Driver, unpack it and install it once (needs make, gcc, the kernel headers and dkms):

tar -xzf peak-lin-driver-*.tar.gz
cd peak-lin-driver-*
make
sudo make install
sudo modprobe plin

Each LIN channel is then a device /dev/plin0, /dev/plin1, ... (the list in the bus dialog shows them). On a PCAN-USB Pro FD the CAN channels stay with SocketCAN (can0, can1); the LIN channels need 12 V on the LIN connector for their transceivers.

Windows: first start

The programs are not signed yet, so Windows SmartScreen may warn when one is started for the first time. Click "More info", then "Run anyway". For CAN, install the PEAK device driver; it brings PCAN-Basic, which XCP-Ray uses. The channels are named PCAN_USBBUS1, PCAN_USBBUS2, ...

Vector adapters (VN1610, VN1630, VN1640, VN89xx and others, also the virtual channels of the Vector driver) work through the Vector XL Driver Library. Install both from www.vector.com: the Vector driver setup (drivers of the devices, also the virtual channels) and the "XL Driver Library", which puts vxlapi64.dll into the Windows system folder. The channels are named Vector: plus the channel name of the driver, e.g. Vector:VN1630A Channel 1 or Vector:Virtual Channel 1 (with two devices of the same kind, the serial number is added). CAN and CAN FD, listen-only, the bit rate set by XCP-Ray, hardware time stamps and the bus state. If another program already uses the channel with init access (e.g. CANoe), XCP-Ray measures with that program's bit rate and says so in the log.

Adapters of other vendors (Kvaser, ETAS, IXXAT, Intrepid and others) work through their SAE J2534 ("PassThru") driver, which comes with the adapter's driver package. The channel is named J2534: plus the device name of the driver, e.g. J2534:Kvaser J2534; the channel list of the ECU and bus dialogs shows the installed J2534 drivers. Limits of J2534:

A driver that is not registered can be used with its path: J2534:C:\path\to\driver64.dll.

The main window

Overview

Projects

A project (.x1p) holds the ECUs and buses with their settings, the pages and displays with their signals and settings, the DAQ events, the name display and the window layout. Paths to A2L and DBC files are stored relative to the project.

ECUs and buses

Devices > ECUs and buses lists all ECUs and buses with Edit and Remove. When it opens, the columns fit their contents (the name and the buttons always complete); drag the column borders to change the widths. The tick in front of an ECU or bus switches it off and on again (also with a right click on its name in the toolbar): switched off, it stays in the project with all its settings and its signals in the displays, but is not connected or measured, so it raises no errors while it is not on the bench (an ECU) or its adapter is not plugged in (a bus: otherwise a channel that cannot be opened stops the start of the measurement). Its name is grey, the Status tab shows "switched off", and the project remembers it ("enabled": false; for an ECU also read by xcpray-cli -c). The column "CMD/RES" shows the CAN-IDs of a CAN ECU, else the transport (UDP, TCP or serial with its baud rate). Devices > Add ECU opens the ECU dialog. Its tab "Connection" holds the connection, the tab "XCP" the protocol settings (see "XCP settings").

FieldMeaning
Nameshort name used in signal names (NAME:signal); default: the MODULE name of the A2L
A2L filethe description of the ECU
TransportXCP on CAN, XCP on UDP/IP, XCP on serial (with text console), or XCP on TCP/IP
CAN interfacee.g. can0 (Linux), PCAN_USBBUS1, Vector:<channel> or J2534:<device> (Windows); the list shows the attached channels
Bitrate [bit/s]set by XCP-Ray; default from the A2L
CAN FDXCP on CAN FD (up to 64 bytes per frame, faster data phase): from the A2L (on when its XCP_ON_CAN has a CAN_FD block), off or on. All ECUs and buses on one channel need the same setting: choosing a channel that a bus or ECU already uses takes its setting, and a different choice is pointed out before Add
Data bitrate [bit/s]CAN FD: the bit rate of the data phase, set by XCP-Ray; default from the A2L (CAN_FD_DATA_TRANSFER_BAUDRATE)
CMD CAN-ID, RES CAN-IDmaster to ECU and ECU to master; default from the A2L
Host, PortXCP on UDP/IP and TCP/IP: address of the ECU (also a name such as x1-esp32.local); default from the A2L, port 5555
Port, Baud rateserial: the port (the list shows USB serial ports, any path can be typed) and the baud rate (default from the A2L, else 115200)
Reset delay [ms]serial: waiting time after opening the port; opening it resets an Arduino Nano, whose boot loader runs 1 to 2 s. 0 for boards without reset
Reconnectafter a lost connection: abort, retry (Reconnect attempts times) or retry forever
Poll period [ms]how often values that are not measured by DAQ are read (see "Value display"); 0 = never
Max. bus load [%]a measurement that would load the bus more is refused
Default DAQ eventevent of measurements that have none in the A2L

Two buttons of the ECU dialog move an ECU between projects:

ECUs and buses on the same interface share the CAN channel; the bus load is summed per channel. CAN, UDP and TCP ECUs can be measured together. Renaming an ECU or a bus renames its signals in all displays (with their axes, colors, limits and DAQ events) as well.

Devices > Add CAN bus (DBC) adds a bus as a source of its own: name, DBC file, interface, bitrate, CAN FD. It is passive: the messages are decoded and recorded during every measurement, nothing is sent - unless you simulate frames of it (Restbus simulation). Its signals are named BUS:Message.Signal. DBC files of generators (e.g. opendbc) with a faulty comment, attribute or value table load all the same: the faulty line is skipped and named in the log.

Devices > Add LIN bus (LDF) adds a LIN bus: name, LDF file, LIN interface, baudrate (empty: the speed of the LDF) and the role of the PC:

Its frames are decoded and recorded during every measurement like those of a DBC; their signals are named BUS:Frame.Signal. Headers without (valid) response are counted (Status tab). LIN adapters: PEAK PLIN-USB, PCAN-USB Pro and PCAN-USB Pro FD - on Linux through PEAK's LIN driver (see "Linux: LIN with PEAK", channels /dev/plin0, ...), on Windows through the PLIN-API of PEAK's device driver setup (install it with the LIN option; channels PLIN:<device>.<channel>, e.g. PLIN:1.1). vlin:<name> is a virtual LIN bus inside XCP-Ray (to try it without hardware). Vector LIN adapters follow.

Devices > Connect all and Disconnect all act on all ECUs. Disconnecting a serial ECU releases the port, e.g. for flashing the firmware. When the board is unplugged, the port is released at once and the ECU shows as disconnected (the board restarts when it is plugged in again); Connect connects again. During a measurement it reconnects by itself once the board is back.

XCP settings

When it connects, XCP-Ray asks the ECU for its protocol and DAQ parameters. The tab "XCP" of the ECU dialog shows them, and every one can also be set by hand, e.g. for an ECU that reports a value wrongly or does not know a command:

Seed & Key

Some ECUs lock calibration, measurement or stimulation until they get the key of a seed. The algorithm is secret and different for every ECU, so XCP-Ray does not contain it: it runs a command of yours. Enter it in the ECU dialog, tab "XCP", section "Seed & Key":

Signal browser

Displays

Status

The tab "Status" next to the signal browser shows the live data (click an ECU name in the toolbar to bring it to the front; drag the tab elsewhere to see it together with the signals):

Counters that should stay 0 turn orange or red when they do not.

Page groups, pages and displays

Displays are arranged on pages, and pages in page groups:

Scope

The scope shows signals over time. While measuring it follows the live data ("Follow"); with the mouse wheel and dragging you zoom and move; "Fit" fits all axes. The scope reads the recording, so zooming out shows the whole measurement with a min/max envelope, without losing peaks. Gaps in the data (lost data, reconnect) are shown as gaps.

Value display

One row per signal with its value and unit; parameters can be changed here.

Notes

View > New notes adds a display with your own text, e.g. a test procedure, limits or a warning next to the signals. It behaves like the other displays (pages, page groups, saved with the project).

Bar display

One horizontal bar per signal. "Limits..." sets the scale and the limits min/max per signal (or "Limits of the first row for all"). The bar is green within the limits, orange below min and red above max. The limit marks can be dragged with the mouse; unset limits are faint handles at the ends of the bar; a double click removes a limit.

Curve editor

Opens for a CHARACTERISTIC of type CURVE: signal browser "Open curve editor", or drag the curve onto any display (a curve editor opens for it; dropped onto a curve editor, it replaces the curve shown).

Map editor

Opens for a CHARACTERISTIC of type MAP: signal browser "Open map editor", or drag the map onto any display, as with curves.

Console

For ECUs on a serial line: the text output of the firmware, line by line with the time ("Time" switches it off). Typed lines are sent with a line end (Up/Down recall earlier input). "Follow" keeps the end in view; the right-click menu copies, saves and clears. Connect and Disconnect are in the window itself.

Restbus simulation

A CAN bus with a DBC or a LIN bus with an LDF can stand in for nodes that are not connected: the PC sends their frames. Open it with View > Restbus > *bus* or "Restbus simulation" in the right-click menu of the bus in the signal browser. The display lists all frames of the DBC:

Restbus scripts: counters, checksums and node logic

Many ECUs accept a frame only with a running alive counter and a checksum (CRC, an E2E protection of the manufacturer or of AUTOSAR). XCP-Ray does not build these profiles in: you write them as a small Lua script (Lua 5.4), and XCP-Ray calls its function every time the frame is sent (CAN and LIN). The same script can simulate the logic of a node: values over time, frames that drop out, other frames set from it, and answers to the frames of other nodes (see "Node logic" below).

local crc8 = xr.crc{width = 8, poly = 0x1D, init = 0xFF, xorout = 0xFF}

function counter_crc8(frame, state)
  state.counter = ((state.counter or -1) + 1) % 16
  frame:set("Counter", state.counter)          -- a signal of the DBC, raw value
  frame[0] = crc8(frame, 1, #frame - 1)        -- CRC over bytes 1..7 into byte 0
end
In the scriptMeaning
frame[i]byte i (0 = first byte, as in the DBC), read and write, 0..255
#frame, frame.name, frame.idlength, name and identifier of the frame
frame:get("Signal"), frame:set("Signal", raw)raw value of a signal of the DBC (not scaled)
frame:value("Signal")physical value of a signal (factor, offset and sign applied)
return falseskip this transmission (nothing or anything else: the frame is sent)
xr.crc{width, poly, init, xorout, refin, refout}a CRC of 1..64 bits with the parameters of the CRC catalogues (refout as refin if not given)
crc(frame, first, last, ...)the CRC over the bytes first..last, followed by further bytes, e.g. a data ID
crc:start(), crc:update(r, ...), crc:finish(r)the same in steps, e.g. data ID first, then the bytes
print(...)a line in the log

Node logic. Inside the functions the script also reaches the rest of the bus:

In the scriptMeaning
xr.time()seconds since the script was loaded (for values over time, timeouts)
xr.rx("Frame")the frame received last from another node, read-only ([i], get, value), with .age in seconds; nil if none came since the bus was connected
xr.restbus("Frame")another frame of the simulation: :get("Signal") and :set("Signal", value) (physical value or text of the value table), :send(), :set_active(true/false), :set_cycle(ms), .active, .cycle
function on_receive(frame, state)if the script defines it: called for every frame of the DBC/LDF received from another node while the simulation runs
local command = xr.restbus("Gw_Command")   -- a frame the PC sends, cycle 0 (only on change)

function on_receive(frame, state)          -- answers at once, not in the next cycle
  if frame.name == "Ecu_Status" and frame:value("Temperature") > 90 then
    command:set("Fan_Setpoint", 100)
  end
end

function every_third(frame, state)         -- a frame that drops out: 2 of 3 skipped
  state.n = (state.n or 0) + 1
  return state.n % 3 == 0
end

On LIN the adapter answers each header on its own from its buffer. The function of a frame therefore prepares the bytes of the next transmission: once when the simulation starts (or the frame is ticked) and again after each transmission. A counter counts every transmission as on CAN; a value set meanwhile goes out one transmission later. If the function fails or returns false, the bytes sent last are sent again (before the first good bytes the frame is not answered). :send() and :set_cycle() have no effect on LIN (the schedule decides). While another program (e.g. PLIN-View) has the same PEAK LIN channel open, the driver refuses changed bytes: close it, or the frames keep their old data.

On a LIN bus the schedule decides when a frame is on the bus: the cycle column shows the mean cycle in the first schedule table and cannot be changed, there is no "Send". A ticked frame is answered by the PC (its header comes from the PC as master or from the real master); a changed value is in the next answer. As slave, simulate only frames of nodes that are not on the bus - two answers to one header are a collision.

Bus log

The tab Bus log on the left (next to Signals and Status) lists every frame of a CAN bus with a DBC or a LIN bus with an LDF while the bus is connected - with or without a measurement, also frames the DBC/LDF does not know, and the frames the PC sends itself (restbus simulation, "Tx"). Choose the bus in the list at the top.

Measuring and recording

Measuring

Measurement > Start (F5) measures every measurement shown in a display, on all connected ECUs, and records all of them together with all received DBC messages. Measurement > Stop (F6) ends it. Closing XCP-Ray while measuring asks first; "Stop and close" stops the measurement, packs the recording and then closes.

DAQ configuration stored in the ECU (RESUME mode)

Configuring the DAQ lists takes one command per signal and some time on CAN (about 0.2 s for 100 signals at 500 kbit/s). An ECU that offers it (RESUME_SUPPORTED, e.g. the simulator with --nvm and the XMC4700 test ECU) can keep the configuration in its non-volatile memory: Measurement > Stored DAQ configuration > ECU while a measurement runs:

Measuring from the power-up (cold start): after "Store with RESUME" the project keeps the stored configuration with the ECU (save the project). When this ECU does not answer, Measurement > Start (F5) still starts: the measurement waits for the ECU ("waiting for the ECU (RESUME mode)"), records its data from the first millisecond after it is switched on, and connects as soon as it answers ("connected to the ECU, measuring since its power-up"). This is the procedure of the XCP standard: the ECU sends EV_RESUME_MODE with the id of the configuration and its data before any CONNECT. The stored signals are measured, whatever the displays show. In xcpray-cli, measure --store-daq --resume with -c FILE writes the stored configuration into FILE; a later measure with that file waits for the ECU when it does not answer.

On ECUs with a larger MAX_CTO (CAN FD, Ethernet) XCP-Ray writes several entries of a DAQ list per command (WRITE_DAQ_MULTIPLE), which also shortens the start; ECUs without it get one per command.

Triggers

A trigger watches a measured signal and marks the moment its condition comes true, e.g. to find a rare fault in a long measurement. Measurement > Triggers opens the list (the menu shows how many triggers are switched on):

ColumnMeaning
Onthe trigger is checked in the next measurement
Nameshown in the log, the markers and the file names
Signala measurement of an ECU or a signal of a bus; it is measured also if no display shows it
Conditionrising above, falling below, crossing (both), leaving the range (two values), equal to
Valuethe threshold in the unit of the signal (the range: lower and upper value)
Pre, Post [s]the window before and after the hit
Maxat most this many hits per measurement (0 = no limit)
Exportafter the measurement one file per hit with its window, MDF4 or CSV

Datasets

A dataset holds all parameters of an ECU: every value, curve, map, value block (VAL_BLK, in DCM FESTWERTEBLOCK) and text (ASCII, in DCM TEXTSTRING) of its A2L. It is saved as a DCM file (DAMOS DCM 2.0), which other calibration tools read as well.

Calibration pages

An ECU can keep its calibration data in several pages of a segment, e.g. a reference page (the values of the firmware, in flash, read only) and a working page (in RAM). Two things are chosen separately: the page the ECU runs on and the page XCP-Ray reads and writes.

Recordings

Recordings go into the folder recordings next to the project, or into one folder for all projects (File > Settings), one per measurement, named after the project, then date and time: motor_test_20261016-183220 (unnamed_... for a project not saved yet). After the measurement the folder is packed into one file NAME.x1rec (File > Settings can switch this off). Both forms can be opened.

When a measurement stops, a dialog asks for a title and notes (e.g. "cold start at -10 °C", what was done, what was seen); Ctrl+Enter saves. The file name below is filled in as described above and can be changed: Save renames the recording (a name that is not allowed or already there is shown in red). Skip notes (or Esc) keeps the recording without them, under its file name; they can be added later. Delete recording... removes the recording of this measurement from the disk right away, after a confirmation (e.g. a test run that went wrong). The title and notes are kept in the recording. The tab Recording on the left (next to Signals and Status, there while a recording is shown) shows them with the file, start time, length, size, signals and sources, and changes them later (Save); for a packed recording the change is kept in a small file next to it, NAME.x1rec.notes.json - copy it along. The MDF4 export puts them into its header comment, x1-rec FILE prints them. File > Settings switches the question off.

Every value written while recording (a parameter, an overwritten measurement, a curve or a map) is kept in the recording as an event with its time and new value, e.g. write XMC:sim_amplitude = 18.000 V. The time is when the value reached the ECU; the value is the one read back from it. The scopes mark events with a dashed line and a label, live and offline (hover for the time and the full text); the MDF4 export contains them as markers.

The parameters shown in displays when the measurement starts (values and curves) are also recorded as channels, in the group "Calibration" of their ECU: their value at the start and their new value after every write, without any bus load. Offline and in other tools (e.g. asammdf) they appear as signals like measurements, a curve as one channel per point (NAME[0], NAME[1], ...); texts of enumerations stay texts. A scope shows them as steps across its whole width: each value holds until the next write (live up to now, offline up to the end of the recording). Maps are not recorded as channels; their event lists the written values.

The free disk space is watched: below 200 MB no measurement starts; below 1 GB, or when the disk would be full within an hour, the toolbar shows a warning; below 200 MB a running measurement is stopped cleanly.

Offline analysis

File > Open recording (or xcpray-gui -r FILE) shows the recording in the signal browser as additional nodes. The dialog shows the title of every recording in the column Title; on the right, the selected one with its whole title, its notes, start time, signals and sources. Its signals can be searched and dragged into displays like live signals. With a scope cursor set, value and bar displays show the values at the cursor time; without one, the last recorded values.

File > Import CSV or MDF4 turns a CSV or MDF4 file into a recording and opens it. The recording is written to the recordings folder as <name of the file>_csv or _mf4; the import runs in the background with its progress in the toolbar.

MDF4 (.mf4, .mdf, ASAM MDF 4.x), e.g. from CANape, INCA, CANoe, a data logger or asammdf:

CSV, e.g. data from a data logger, from Python or from Excel, or a CSV that XCP-Ray exported:

Export

File > Export recording (while a recording is open):

The export runs in the background with its progress in the toolbar. On the command line: x1-rec RECORDING --export FILE.mf4 (or .csv, with --csv-de).

Settings and keys

Program settings

File > Settings (stored per user: Linux ~/.config/xcpray/settings.json, Windows %APPDATA%\xcpray\settings.json, independent of the project):

Scripts (Python)

Scripts on this computer can read and write values while XCP-Ray is connected, start and stop measurements and put markers into the recording, e.g. to play a stimulus during a test.

import xcpray
with xcpray.connect() as ray:
    ray.start_measurement()
    ray.write("ENGINE:sim_amplitude", 20)
    print(ray.read("ENGINE:sim_sine"))
    ray.marker("step done")
    ray.stop_measurement()
    ray.restbus_start("BODY")                        # a LIN or CAN bus of the project
    ray.write("BODY:BCM_Wiper.WiperMode", "fast")    # the value the restbus sends
    print(ray.read("BODY:Wiper_Status.WiperPosition"))  # from the last frame on the bus

The interface is JSON-RPC 2.0 over TCP, one JSON message per line; describe lists its methods with their parameters, so other languages can use it as well. The first message authenticates:

{"jsonrpc":"2.0","id":1,"method":"auth","params":{"token":"..."}}

Without it, or with a wrong token, the answer is the error -32001.

Updates, support and problem reports

Updates at start: XCP-Ray asks the XCP-Ray server for the newest version at every start (File > Settings > "Check for updates at every start", default on; also in the update dialog). Only the version file is requested, nothing about you, your projects or measurements is sent; the server counts the requests per month and system (Linux, Windows), without IP address. The dialog shows up only when there is a newer version; otherwise, or without a connection, the log gets one line. Apart from that, XCP-Ray goes online only when you choose it in the Help menu.

Help > Check for updates... asks the XCP-Ray server for the newest version. If there is a newer one, the dialog lists what changed since your version; "Open download page" opens it in the browser. Download the package and unpack it in place of the old one: projects and settings stay.

Help > Request support... asks the developers of XCP-Ray for help, for example when your adapter or ECU does not connect or you are not sure how to set something up. Describe what you want to do, your adapter, the ECU or board, and what you tried. An e-mail address is needed: the answer comes by e-mail, usually within 5 working days. The address is only used to answer you and is deleted with the request. You can also write to support@xcp-ray.de.

Help > Report a problem... sends a description of a problem to the developers of XCP-Ray. Describe what happened and what you expected. The e-mail address is optional; with it you get an answer, usually within 5 working days.

Both dialogs send the same report; you choose what goes with it:

The version of XCP-Ray and the operating system are always included; recordings never. "Save as zip..." writes the same report into a file instead, to look at it first or to send it another way; nothing is sent then.

Linux uses the program curl (or wget) for both; a proxy is taken from https_proxy. Windows uses the proxy of the system settings.

Keyboard

KeyAction
F1this manual
F5 / F6start / stop the measurement
Ctrl+N, Ctrl+Onew project, open project
Ctrl+S, Ctrl+Shift+Ssave project, save project as
Ctrl+Ddisplay names (DISPLAY_IDENTIFIER) on/off
Cscope cursor on/off (in a scope)
Left / Rightmove the scope cursor to the previous / next sample
Ctrl+Ccopy the selected log lines

Command line of the GUI

xcpray-gui                                   empty project (or the last one, see settings)
xcpray-gui bench.x1p                         open a project (the same as -P bench.x1p)
xcpray-gui -P bench.x1p --measure            open, connect and start measuring
xcpray-gui -c ecu.json [-c other.json]       ECUs from session configurations (see xcpray-cli)
xcpray-gui -r recordings/20261005-163248.x1rec   open a recording

--connect connects at the start, --search TEXT fills the search of the signal browser.

Command-line tools

xcpray-cli

xcpray-cli connects to one ECU, reads and writes values, curves and maps, and measures. The connection is given by options or by a session configuration (JSON); options override the configuration, and everything not given comes from the A2L.

xcpray-cli --a2l ecu.a2l -i can0 -b 500000 --cmd-id 0x783 --res-id 0x782 info
xcpray-cli --a2l ecu.a2l --udp 192.168.1.50:5555 info
xcpray-cli --a2l nano.a2l --serial /dev/ttyUSB0:115200 info

Connection options:

OptionMeaning
-c, --config FILEsession configuration (JSON), written by save-config
--a2l FILEA2L file
-i, --interface NAMECAN interface (can0, PCAN_USBBUS1, Vector:<channel>, J2534:<device>)
-b, --bitrate NCAN bitrate in bit/s, set by the tool
--fd, --no-fdXCP on CAN FD on or off (default: from the A2L, CAN_FD in XCP_ON_CAN)
-d, --data-bitrate NCAN FD data bitrate in bit/s, set by the tool
--cmd-id ID, --res-id IDCAN-IDs master to ECU and back (A2L notation, e.g. 0x783)
--udp HOST[:PORT]XCP on UDP/IP instead of CAN
--tcp HOST[:PORT]XCP on TCP/IP instead of CAN
--serial PORT[:BAUD]XCP over a serial line instead of CAN
--reset-delay MSserial: waiting time after opening the port (default 2000)
--no-short-uploaddo not use SHORT_UPLOAD
--seed-key COMMANDSeed & Key: command that writes the key for a seed (see "Seed & Key")
--xcp-page Pcalibration pages: read and write page P of segment 0 for this command
--reconnect POLICYabort, retry or retry_forever
--jsonmachine-readable output (see below)
-v, --verboselog details

Commands:

CommandPurpose
infoECU, resources, DAQ capabilities and events
list [PATTERN] [-p] [-m]search the A2L (no connection); -p only parameters, -m only measurements
get NAME ...read values (physical value with unit, or the text)
set NAME=VALUE ...write parameters (number or text) and read them back; -m also measurements
curve NAME [--set V ...] [--set-axis X ...]read a curve, or write its values or axis points
map NAME [--set V ...]read a map, or write its values row by row (all x of the first y, then of the next y)
measure [-s NAME[@EVENT] ...] [-t S] [-r DIR] [-p N] [--store-daq [--resume]]measure for S seconds (0: until Ctrl+C), record into DIR, print every N-th record; --store-daq stores the DAQ lists in the ECU once started, --resume also starts them at every power-up of the ECU
stored-daq [--clear]show the DAQ configuration stored in the ECU (RESUME mode), or remove it
pages [--segment N] [--ecu P] [--xcp P] [--copy FROM TO]calibration pages: show the segments and pages, switch pages, copy a page
console [-t S]serial: show the text output of the ECU; lines from stdin go to the ECU
save-config FILEwrite the effective configuration to a file
xcpray-cli --a2l ecu.a2l -i can0 --cmd-id 0x783 --res-id 0x782 --reconnect retry save-config ecu.json
xcpray-cli -c ecu.json list Temperature
xcpray-cli -c ecu.json get engine_speed gain
xcpray-cli -c ecu.json set gain=2.5 mode=SPORT
xcpray-cli -c ecu.json map ignition_map --set 1 2 3 4 5 6
xcpray-cli -c ecu.json measure -s engine_speed@10ms -s coolant -t 60 -r run1.rec

measure watches the connection; with --reconnect retry it reconnects and restarts the measurement after a lost connection, and the recording continues with a gap. An ECU in RESUME mode goes on sending through its reset: the measurement continues without configuring again. Exit code 2 means the measurement ended because the connection failed.

JSON output

With --json, xcpray-cli prints machine-readable JSON on stdout; messages stay on stderr. Each command prints one JSON document:

measure and console print one JSON object per line (JSON Lines): measure a line {"type": "start", "signals": [...]}, then {"type": "record", "t", "list", "values": {...}} per printed record and {"type": "summary", ...} at the end; console one line per text line with time, unixMs, kind (output, input, info) and text.

Errors are printed as {"error": {"context", "code", "message"}} with exit code 1. Values that are not finite are printed as null.

$ xcpray-cli -c ecu.json --json get mode
{"values":[{"name":"mode","kind":"parameter","value":1.0,"text":"ON","unit":"","lower":0.0,"upper":1.0,"writable":true}]}

Session configuration

save-config writes a configuration that xcpray-cli -c and xcpray-gui -c read:

{
  "a2l": "ecu.a2l",
  "can": { "interface": "can0", "bitrate": 500000, "cmdId": "0x783", "resId": "0x782", "fd": true, "dataBitrate": 2000000 },
  "udp": { "host": "x1-esp32.local", "port": 5555 },
  "serial": { "port": "/dev/ttyUSB0", "baudrate": 115200, "resetDelayMs": 2000 },
  "xcp": { "useShortUpload": true, "queryDaqInfo": true,
           "seedKey": { "command": "python3 key.py", "resources": ["cal", "daq"], "timeoutMs": 10000 },
           "overrides": { "maxOdtEntrySize": 7, "timestampSize": 2, "timestampTickUs": 1000,
                          "events": [ { "channel": 0, "name": "10ms", "cycleMs": 10 } ] } },
  "daq": { "defaultEvent": 0, "maxBusLoad": 0.8 },
  "reconnect": { "policy": "retry", "attempts": 5 }
}

Only one of can, udp, tcp and serial is used ("tcp": { "host": "...", "port": 5555 } is XCP on TCP/IP); a relative A2L path is relative to the configuration file. overrides holds the manual XCP settings (see "XCP settings"): byteOrder (Intel, Motorola), addressGranularity (1, 2, 4), maxCto, maxDto, dynamic, maxDaq, identification (absolute, relativeByte, relativeWord, relativeWordAligned), overload (none, pid, event), prescaler, granularity, maxOdtEntrySize, timestampSize, timestampTickUs, timestampFixed and events.

xcp-sim

xcp-sim vcan0 --a2l sim.a2l                    XCP on CAN (CMD 0x7F0, RES 0x7F1), writes its A2L
xcp-sim udp --udp 5555 --a2l udpsim.a2l        XCP on UDP/IP (--local: only this computer)
xcp-sim tcp --tcp 5555 --a2l tcpsim.a2l        XCP on TCP/IP (one master; a new connection replaces the old one)
xcp-sim serial --serial /tmp/x1tty --a2l s.a2l XCP over a pseudo terminal with text output (Linux)
xcp-sim vcan0 --dbc bus.dbc --no-xcp           only send the DBC messages with test patterns

Further options: --fd, --bitrate, --cmd-id, --res-id, --motorola, --max-cto, --no-daq-info (the ECU does not know GET_DAQ_RESOLUTION_INFO and GET_DAQ_EVENT_INFO), --signals N (additional load-test signals), --drop P and --delay-us N (fault injection), --protect cal,daq,stim and --seed-length N (Seed & Key: lock these resources until the key arrives; the key is byte i of the seed XOR 0xA5 + i, see examples/seed-key/xor_key.py), -v (statistics every second), --text-every N (a text message to XCP-Ray every N seconds while connected, for the log).

--nvm FILE gives the simulated ECU non-volatile memory in a file: it can store a DAQ configuration and starts it in RESUME mode at the next start (see "DAQ configuration stored in the ECU").

Besides scalars, curves and maps the simulator has two measurement arrays: sim_cells, 16 cell voltages of a battery (cell 11 a little weaker), and sim_matrix, 3 x 4 values (10 x row + column plus a slow sine).

x1-rec

x1-rec run1.x1rec                          groups, signals, sample counts
x1-rec run1.x1rec -s sim_sine -c 20        min/max of a signal over 20 time slices
x1-rec run1.x1rec -s sim_sine --samples 10 the first 10 samples
x1-rec run1.rec --pack [--keep]            pack a recording folder into one .x1rec file (compressed)
x1-rec run1.x1rec --export run1.mf4        export (.mf4 or .csv; --csv-de for German Excel)
x1-rec data.rec --import data.csv          import a CSV file into a new recording folder
x1-rec data.rec --import data.mf4          import an MDF4 file into a new recording folder
x1-rec log.rec --import log.mf4 --dbc car.dbc            ... its CAN frames decoded with a DBC
x1-rec log.rec --import log.mf4 --dbc 1=pt.dbc --dbc 2=body.dbc   one DBC per channel of the logger

A packed recording is a tar file; tar xf NAME.x1rec gives the folder (the measured data in compressed files gNNNN.recz; XCP-Ray opens the folder as it is). --no-compress packs without compression; older uncompressed files open as before.

x1-a2l and x1-dbc

x1-a2l ecu.a2l                         statistics of the A2L file
x1-a2l ecu.a2l -f engine_speed -w      details of objects, all warnings
x1-dbc bus.dbc                         summary and warnings
x1-dbc bus.dbc --list                  messages and signals
x1-candump can0 | x1-dbc bus.dbc --decode -     decode frames (Linux)

x1-elf2a2l

Creates an A2L file from the ELF file of a firmware: addresses and data types come from the DWARF debug information, a short variable list (JSON) selects the variables and adds units, conversions, limits, events and the XCP transport.

x1-elf2a2l firmware.elf --list 'sensor_*'               variables of the ELF file
x1-elf2a2l firmware.elf -v variables.json -o ecu.a2l    create an A2L file
x1-elf2a2l firmware.elf --update old.a2l -o new.a2l     new addresses and types for an A2L

Characteristic curves and maps come from arrays: a curve from two one-dimensional arrays of the same length (axis points and values), a map from a two-dimensional array values[y][x] and one axis array for x and y each. Curves and maps may share an axis.

{ "name": "gain", "unit": "%", "curve": { "axis": "gain_x", "input": "rpm", "unit": "1/min" } }
{ "name": "spark", "unit": "deg",
  "map": { "x": { "axis": "spark_x", "input": "rpm" }, "y": { "axis": "spark_y", "input": "load" } } }

--update keeps the existing A2L (conversions, units, comments) and only takes addresses and data types from the ELF; --details lists every change. The kits contain examples of variable lists and explain curves and maps.

Variables without debug information, e.g. of an Arduino IDE build for AVR boards (it uses LTO, which drops them from DWARF): give their type in the list, "type": "uint16_t" (also int8_t ... int64_t, bool, float, double or the A2L names like UWORD); the address then comes from the symbol table. Curves need the "type" of the values and, inside "curve", of the axis. Alternatively switch LTO off in the Arduino IDE for AVR boards with a platform.local.txt next to the platform.txt of the AVR core (the four compiler.*.flags lines without the LTO options; the guide of the kit shows them): then the debug information is complete, for all sketches of that core, and the firmware gets about 2 KB larger.

The kits are also libraries for the Arduino IDE and PlatformIO (see "Arduino, ESP32 and ESP8266").

x1-a2l-studio

A window to build or update an A2L file from an ELF file, and to see and edit every entry of an A2L (tab "A2L editor"): a table of every scalar variable of the ELF matched with the A2L (status same, changed, check, A2L only, ELF only), conversion rules by typedef (unit, factor, offset, format, limits, also taken from the names, or from a Lua script; with "Rules overwrite existing conversions" also for objects that already have a conversion, and a changed rule updates the limits of its objects), "Add" and "Don't add" for selected variables, "Update A2L" (Ctrl+U, keeps the previous file as .bak) or "Export...". Unchanged parts of the A2L stay byte for byte as they are. XCP-Ray starts it with the A2L of an ECU (see "Updating the A2L with A2L Studio").

x1-a2l-studio --elf fw.elf [--a2l ecu.a2l] [--rules my.x1rules] [--script my_rules.lua]
x1-a2l-studio --elf fw.elf --a2l ecu.a2l --rules my.x1rules --update     batch mode

Placeholders. A rule can take values from the name of the typedef or the variable: {factor}, {offset} and {unit} in a pattern. The typedef pattern T_{factor}_{unit} gives T_0p1_degC the factor 0.1 and the unit °C, and T_Q8_mV the factor 1/256 and the unit mV; the variable pattern *_{unit} takes the unit from the last part of the name (Batt_U_mV). Numbers can be written 10, 0.1, 0p1 (p = decimal point), m40 (-40), E2, Em2 (0.01), Q8 (2^-8), x10 (times 10) or d10 (divided by 10). The unit table of the Rules tab turns the text of the name into the unit of the A2L (degC -> °C, pct -> %, rpm -> 1/min, ...; the table is saved with the rules). Each combination gets its own COMPU_METHOD (e.g. X1R_phys_0p1_degC). If a value is not understood (T_abc_mV), the rule does not apply and the table shows a note (filter "with a note"). "Try" in the Rules tab shows what a typedef gets.

Rule script. For naming conventions the rules cannot express, a Lua script (Rules tab, "New script..." writes one with examples) is asked for every variable before the rules. It can define four functions, each gets a table with the name, the typedefs, the C and A2L type, the size, the address, bit mask, enumeration texts and whether the A2L has the object already:

function conversion(v)   -- a table, false (no conversion) or nil (the rules decide)
  local f, u = v.typedef and v.typedef:match("^T_%a+_(%w+)_(%w+)$")
  if f and xr.number(f) then return { factor = xr.number(f), unit = xr.unit(u) } end
end
function kind(v)    if v.name:match("^K_") then return "parameter" end end
function exclude(v) return v.name:match("^Dbg_") ~= nil end   -- never added, not changed
function add(v)     return v.name:match("^Sig_") ~= nil end   -- proposed for adding

conversion can also return offset, format, min, max, description, name (of the COMPU_METHOD) and texts = {[0] = "off", [1] = "on"} (a value table). xr.number() reads numbers as in names, xr.unit() uses the unit table, print() writes into the log. Excluded variables have the status "excluded". The script is stored with the rules (path relative to the rule file); Studio reloads it when the file is saved. Like the restbus scripts it cannot read files or start programs, and a script that runs too long is stopped.

If the A2L already has a COMPU_METHOD with the same values (unit, factor, offset, and the format if the rule gives one), Studio uses it instead of writing a new one.

A2L editor. The tab "A2L editor" shows every block of the loaded A2L: a list (filter by kind, search by name or description; "all blocks" also shows nested blocks like IF_DATA) and the selected block on the right:

Every change is checked: if the A2L could not be read any more, nothing changes and the error is shown. Undo and Redo (Ctrl+Z, Ctrl+Y) go back to the loaded file; "Save A2L" (Ctrl+S) writes it and keeps the previous file as .bak, everything not edited stays byte for byte as it was. Save (or undo) the changes before "Update A2L" or "Export"; an A2L with /include is edited without the included files.

Arduino, ESP32 and ESP8266

The kits extend existing firmware with XCP:

The libraries are open source (MIT) and work in the Arduino IDE and in PlatformIO:

The example firmware/pico-calibration in the repository shows two more features on a Pico: calibration pages (a reference page in flash, a working page in RAM) and a calibration locked by Seed & Key. Both are compiled in with -DX1_XCPSLAVE_SEED_KEY=1 -DX1_XCPSLAVE_PAGING=1 and are off by default (they need program memory); x1xcp::Config then has segments, onEcuPage, protectedResources, makeSeed and checkKey. Its README lists the steps to try.

The A2L file comes from the ELF file of the build and a short variable list (x1-elf2a2l, in bin/ of XCP-Ray):

The README of each library has the steps. In XCP-Ray: Devices > Add ECU with the generated A2L file and the transport "XCP on serial" or "XCP on UDP/IP".

Curves and maps of the firmware are global arrays listed in the variable list (see "x1-elf2a2l"); the firmware interpolates them itself. An Arduino Nano resets when the port is opened (DTR): values written by XCP-Ray are lost with every new connection unless the firmware stores them. A Pico or an STM32 board does not restart: set the reset delay of the ECU to 0 (ECU dialog, tab "Connection").

XCPlite

[XCPlite](https://github.com/vectorgrp/XCPlite) from Vector is an open source XCP on Ethernet server (MIT) for Linux, QNX, Windows and microcontrollers with FreeRTOS. XCP-Ray works with it: add the ECU with transport "XCP on UDP/IP" (or TCP) and its A2L.

A demo for the Infineon XMC4700 Relax Kit with FreeRTOS over Ethernet, without a TCP/IP stack, is on GitHub: [xcplite-xmc4700](https://github.com/flmueller/xcplite-xmc4700) (MIT, with the project xcplite_demo.x1p): signal generator, curve and map, local variables, page switching, CPU load and Ethernet counters. Its README has the steps.

Troubleshooting

Connection problems

A failed connect turns the name of the ECU or bus in the toolbar red; its tooltip and the Status tab show the reason (also in the Log). Connect tries again.

Measurement problems