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
- XCP on CAN and CAN FD (SocketCAN on Linux; on Windows PEAK PCAN-Basic, Vector XL and other adapters through J2534), XCP on UDP/IP, XCP on TCP/IP and XCP over a serial line (e.g. an Arduino over USB) with the text output of the firmware in a console.
- Several ECUs at the same time, each with its own A2L file and connection; signals are named
ECU:NAME. - Measuring with dynamic DAQ lists, the bus load estimated before the start, data losses detected and shown, automatic reconnect after a reset of the ECU.
- Displays: scope, value display, bar display, curve editor, map editor (heat map and 3D), console. Several pages, which can be taken out as windows of their own (e.g. onto a second monitor).
- Recording of all ECUs and buses into one common recording; offline analysis with the same displays; export to ASAM MDF 4.10 and CSV.
- Calibration of scalar parameters (also texts of enumerations), curves and maps.
- Restbus simulation on CAN: the PC sends the frames of nodes that are not connected, with values set live; alive counters and checksums (CRC, E2E) from your own Lua scripts.
The programs
| Program | Purpose |
|---|---|
xcpray-gui | the measurement and calibration tool (this manual, chapters 2 to 6) |
xcpray-cli | measuring and calibration on the command line, also for scripts (JSON output) |
xcp-sim | a simulated ECU (XCP on CAN, UDP/IP, TCP/IP or serial), also sends DBC test patterns |
x1-rec | inspects, packs and exports recordings |
x1-a2l | inspects A2L files |
x1-dbc | shows and decodes DBC files |
x1-elf2a2l | creates or updates an A2L file from an ELF file (DWARF) and a short variable list |
x1-a2l-studio | A2L from and with an ELF file in a window: update addresses, conversion rules, edit every entry |
x1-candump, x1-cansend | SocketCAN 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
- Devices > Add ECU.
- Choose the A2L file of the ECU (the
...button opens the file browser). - Choose the transport and its settings (see "ECUs and buses").
- Click Add. XCP-Ray connects at once and shows the ECU in the signal browser.
- 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.
- Use anyway: the faulty blocks are left out as if they were not in the file (an object that refers to a left-out object is left out too); everything else can be used.
- Choose another A2L... opens the file browser.
- Copy list copies the list, e.g. for whoever made the A2L.
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:
- classic CAN only (no CAN FD), no listen-only mode;
- the bit rate must be one the driver supports (always 500k, usually also 125k, 250k and 1M);
- XCP-Ray is a 64-bit program and needs a 64-bit J2534 driver. Drivers that exist only as 32-bit DLLs are listed as "not usable";
- with several adapters of the same vendor, the driver chooses the device;
- the bus state (error passive, bus off) is not reported; an unplugged adapter is.
A driver that is not registered can be used with its path: J2534:C:\path\to\driver64.dll.
The main window
Overview
- Menu bar: File, Devices, Measurement, View, Help.
- Toolbar below it: Connect, Start measurement / Stop measurement, Disconnect; then one name per ECU and bus in the color of its state (hover for a summary, click for the Status tab, right click for Edit, A2L Studio, Remove and Switch off / Switch on as in Devices > ECUs and buses; not while measuring; an ECU or bus switched off is grey; red after a failed connect, with the reason in the tooltip and in the Status tab, until a connect succeeds or it is disconnected), the records per second, losses (only when there are any), the free disk space when it gets low, and the progress of exports and packing.
- Signal browser on the left: the signals of all ECUs, buses and open recordings.
- Status tab next to the signal browser: the live data of the measurement (see "Status").
- Page groups and pages in the middle: a row of group tabs, below it the pages of the group shown, each page with its own area for displays.
- Log at the bottom: messages of all ECUs. Click a line to select it (Ctrl/Shift+click: several), Ctrl+C or the right-click menu copies, "Copy all" copies the lines shown. Text messages an ECU sends itself (XCP
SERV_TEXT, e.g.XcpPrintof XCPlite) appear with the name of the ECU in brackets:[ENGINE] calibration stored. "ECU texts only" shows only those, the filter field only lines containing all its words (*and?as wildcards).
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.
- File > New project (Ctrl+N), Open project (Ctrl+O), Save project (Ctrl+S), Save project as (Ctrl+Shift+S).
- File > Recent projects: the last 10 projects (missing ones greyed out, "Clear list").
- Unsaved changes are marked with
*in the window title; closing, New and Open ask to save them first. - File > Project history: after every change of the project (displays, pages, page groups, ECUs and buses, triggers, window layout) its state is kept a few seconds later, with the time and what changed (e.g.
page "Engine" removed,ECU SIM renamed to MOTOR). Restore goes back to such a state; the state before is kept first, so a restore can be undone as well. The project file changes only when you save. The newest 50 states per project are kept in the folderhistorynext to the program settings (also for a project not saved yet). Not while measuring; switched off in File > Settings ("Project history"). - Not closed properly: if XCP-Ray crashed or was stopped (killed, power gone) while the project had unsaved changes, the next start opens that project (a new one if it was not saved yet, instead of the project saved last), says so and shows the last state kept in the project history. Open project history opens that project (if another one is open) and the list of its states; restore the newest with one click and save. Not now leaves everything as it is; the states stay in File > Project history. Several XCP-Ray running at once are told apart.
- File > Export project: one zip with a folder holding the project and every A2L (
a2l/; an A2L that includes other files in a folder of its own, together with them) and DBC file (dbc/) it uses, with relative paths. Unpacked anywhere (also with any zip program) it opens as it is. Recordings are not exported. - File > Import project unpacks such a zip next to it (an existing folder is never overwritten) and opens the project.
- A project file can be opened by double click (Linux: after
install-desktop.shin the package) or given on the command line:xcpray-gui bench.x1p.
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").
| Field | Meaning |
|---|---|
| Name | short name used in signal names (NAME:signal); default: the MODULE name of the A2L |
| A2L file | the description of the ECU |
| Transport | XCP on CAN, XCP on UDP/IP, XCP on serial (with text console), or XCP on TCP/IP |
| CAN interface | e.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 FD | XCP 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-ID | master to ECU and ECU to master; default from the A2L |
| Host, Port | XCP 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 rate | serial: 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 |
| Reconnect | after 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 event | event of measurements that have none in the A2L |
Two buttons of the ECU dialog move an ECU between projects:
- From another project... takes an ECU from another project (
.x1p; with several ECUs a list asks for one) or from a session file (.json): A2L file, transport and its settings, the XCP settings with Seed & Key, reconnect and poll period. The dialog shows them; Add (or Apply) takes them over. Displays, pages and triggers of the other project are not taken. - Save as session file... writes the ECU as a session file, e.g. for
xcpray-cli -c(see "Session configuration"). The A2L path is stored relative to the file, or absolute if the two have nothing in common but the root of the file system.
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:
- PC is master: there is no master on the bus (e.g. one slave on the bench). While the restbus simulation runs, the adapter sends the headers of the schedule table (the first of the LDF, or the one chosen) and answers those of the simulated frames; the slaves on the bus answer theirs.
- PC is slave: a master is on the bus. The PC listens and, while the restbus simulation runs, answers the headers of the simulated frames.
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:
- Each row shows the value in use, the ECU's value (after a connect) and the A2L's value (
IF_DATA XCP). Without a tick in "Manual" the value comes from the ECU, else from the A2L, else a default; with the tick the value typed in is used. - Protocol (CONNECT): byte order, address granularity, MAX_CTO, MAX_DTO.
- Communication: the timeouts T1..T7, CONNECT attempts, "Use SHORT_UPLOAD" (switch it off for ECUs that answer SHORT_UPLOAD wrongly; SET_MTA and UPLOAD are used instead).
- Seed & Key: the command for ECUs that lock resources (see below).
- DAQ: dynamic DAQ, MAX_DAQ, identification field, overload indication, prescaler, ODT entry granularity, maximum ODT entry size, timestamp size, tick and "fixed". A value larger than the maximum ODT entry size (e.g. a double with 4 bytes per entry) takes several entries one after the other; they are sampled together. When no value fits next to the timestamp in the first ODT (e.g. only 4-byte values on CAN with a 4-byte timestamp), that DAQ list goes without the ECU's timestamp and its values get the receive time.
- Events: the ECU's and the A2L's event channels; "Manual event list" edits them (channel, name, cycle in ms with 0 for not cyclic, maximum DAQ lists, priority).
- "Use the ECU's values" takes over everything the ECU reported as manual values, "All automatic" removes them. "Ask the ECU for its DAQ parameters" off: the ECU is not asked at all, only the A2L and the manual values count.
- An ECU that does not know GET_DAQ_RESOLUTION_INFO or GET_DAQ_EVENT_INFO gets these values from the A2L automatically.
- Changes take effect at the next connect. The settings are stored with the ECU in the project and in a session configuration (
"xcp": { "overrides": { ... } }), soxcpray-cli -cuses them too;xcpray-cli infosays when manual values are in use.
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":
- After every connect (also after a reconnect) XCP-Ray asks the ECU which resources are locked. For each one you ticked (calibration, measurement, stimulation) it gets the seed from the ECU, runs your command and sends the key back. The log says what happened, e.g.
Seed & Key: calibration, measurement unlocked. - The command is split at spaces, "double quotes" keep spaces in a word (no shell is used). It is called with two more arguments at the end: the resource as hex (
01calibration,04measurement,08stimulation) and the seed as hex. To put them elsewhere, write{resource}and{seed}in the command, e.g.keytool.exe --res {resource} --seed {seed}. - The command writes the key as hex digits to its standard output (spaces, commas and
0xare ignored) and ends with exit code 0. A program that fails, does not answer within the timeout (default 10 s) or writes no hex is reported in the log; the connection stays, but commands for the locked resource are refused by the ECU (ERR_ACCESS_LOCKED). - Any program works: Python (
python3 "C:/keys/key.py"), a small exe, a script. The exampleexamples/seed-key/xor_key.pyis the algorithm of the simulator: startxcp-sim udp --udp 5555 --local --protect cal,daqand use the commandpython3 examples/seed-key/xor_key.py. - The command (not the algorithm) is stored in the project;
xcpray-clitakes it with--seed-key COMMANDor from"xcp": { "seedKey": { "command": "...", "resources": ["cal", "daq"], "timeoutMs": 10000 } }of a session configuration. - The key is computed by your program, so XCP-Ray never sees the algorithm. Keep it out of projects that you pass on.
Signal browser
- One node per ECU, bus and open recording. Right click on an ECU: Connect, Disconnect, Settings, Console (serial ECUs), Remove.
- Search: terms separated by blanks must all match the name, the DISPLAY_IDENTIFIER, the description or the unit;
*and?are wildcards. - Filters: "Meas." (measurements and DBC signals), "Scalar" (parameters of type VALUE), "Curve", "Map".
- Display names (Ctrl+D) shows the DISPLAY_IDENTIFIER of the A2L instead of the full name everywhere.
- Click, Ctrl+click and Shift+click select several signals. Drag them into a scope, onto an axis of a scope, or into a value or bar display.
- Right click on selected signals: DAQ event (for all selected measurements, or back to the default from the A2L or the configuration), New scope, New value display, New bar display, Open curve editor, Open map editor.
- A DBC message can be dragged as a whole: all its signals. The Ev column shows the cycle time of a message.
- A measurement array is a node with its elements (
name[0],name[1], ...); dragged as a whole it adds all of them.
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):
- Measurement: running time, records, records per second, size written, records dropped by the recording (the disk was too slow), free disk space and when it will be full, the source of a live or opened recording, the progress of exports and packing.
- One section per ECU (header in the color of its state): state, interface, A2L, records, records per second, DTOs, lost ODTs, incomplete and missed cycles, overload indications, reconnects, heartbeat failures; for CAN also the frames received and sent, receive overruns, error frames, bus-off and failed sends of the channel (shared with the other ECUs and buses on it).
- One section per bus (DBC): frames, frames per second, records, frames shorter than their signals, unknown multiplexer values.
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:
- Page groups are the upper row of tabs. A new project has the group "Main". View > New page group adds one (with a first page). Drag a group tab out of the main window to get a window of its own, e.g. on another monitor with several pages; closing that window makes it a tab again. A group is either a tab of the main window or an own window (with a frame, the buttons to minimize and maximize, and an entry in the task bar), never a window floating inside the main window. Positions are saved; a window outside the connected monitors is moved into the visible area.
- The tabs on the left (Signals, Status, Bus log, Recording) and the Log can also be dragged out as windows of their own; closing such a window docks the tab back where it was.
- Pages are the tabs of a group. View > New page adds one to the group used last. Drag a page tab to reorder the pages or onto the tab row of another group to move it there (also "Move to page group" in the page menu). A page always belongs to a group: released anywhere else, it docks back into its group.
- Displays are docked on a page: drag their tab or title bar to arrange them, also onto another page. A display always belongs to a page: released anywhere else, it docks back into its page.
- Moving onto a hidden page or group: drag a display onto the tab of another page and hold it there for half a second: the page opens while you keep dragging, and you can drop the display where you want it on that page. Into a page of another group: hold the display over the group tab first, then over the page tab. The same works for a page held over the tab of another group. The tab is highlighted and fills up while you hold it.
- While you drag a display or a page, it is small and half transparent, so the tabs and the docking targets under it stay visible; docked, it takes the size of its place.
- New displays (View > New scope, New value display, New bar display) go onto the page shown in the group used last; View > Console opens the console of a serial ECU.
- Names of groups, pages and displays cannot contain
#(it is removed, with a note in the log). - Right click on a group tab: rename (Enter), Color, New page, New page group, Delete page group (move its pages to another group, or delete them with their displays).
- Right click on a page tab: rename, Color, New page, Move to page group, Delete page (move its displays to another page or delete them with it).
- Right click on the tab or title bar of a display: rename, Color, Move to page, Delete. A display is deleted only after a confirmation.
- The selected tab of a row shows a close button (X), the others show it under the mouse. It deletes the display, page or page group, with the same confirmation as in the right-click menu; the last page and the last page group have none. A page group taken out as an own window closes with it into the main window again (nothing is deleted).
- Color (group, page and display tabs): one of the eight colors, or "custom" for any color (it is applied while you choose, "None" removes it). The selected tab and the title bar show the color as it is, unselected tabs set off from it (darker in the dark theme, lighter in the light one) with grey text, and the line under the tabs takes the color of the selected tab; the text turns black or white, whichever is easier to read, so also light colors stay readable.
- View > Tab width makes all group, page and display tabs equally wide: "Minimal" (as wide as the title) or 6 to 30 characters. Shorter titles are filled up and centered, longer ones are shortened with "..." and shown whole as a tooltip over the tab. It is kept in the settings.
- View > Reset layout arranges the windows anew, after a confirmation: the signal browser, the log and the page groups go back into the main window, on every page the scopes go into the middle and the other displays to the right, up to three one above the other (more as tabs); a page with only scopes or only other displays uses its whole width. Pages, displays and their settings stay. Displays opened from a project without a saved layout are arranged the same way.
- When a display or page docks back, a dialog explains that only page groups can be own windows; "Don't show this again" switches it off (on again in File > Settings).
- The dialogs about a group, page or display (delete, docked back) appear in the middle of that window, also when its group is an own window on another monitor, which comes to the front.
- Projects from before page groups get the group "Main" with all pages; a page that was taken out as an own window becomes a group of its own at that place.
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.
- Axes...: up to ten Y axes. A table assigns the signals to the axes, or "By unit", "One axis each", "All on Y1". A right click on a signal name or dragging a signal onto an axis does the same. Axes alternate left and right and are drawn in the color of their first signal.
- Stack: the Y axes are scaled so that their values do not overlap; with n axes each one gets a band of 1/n of the height. It works per axis: signals that share one axis are not stacked (give them axes of their own with Axes..., e.g. "One axis each"; the tooltip of Stack says so).
- Steps: samples are connected as steps (value held until the next sample).
- Cursor (key C): a measurement cursor; drag the line, Left/Right step to the previous/next sample. The time and the value of every signal at the cursor are shown ("-" in a gap).
- Sync (also View > Synchronize scope cursors): the cursor moved last sets the time of all other scopes.
- Right click on the plot or an axis opens the plot menus (legend, grid, Auto-Fit of an axis, ...). All these settings are saved in the project; a visible range only when it is locked (Lock Min/Max in the axis menu), so zooming never changes the project file.
Value display
One row per signal with its value and unit; parameters can be changed here.
- Values that are not measured by DAQ (parameters, and all values while no measurement runs) are read from the ECU every "Poll period" of the ECU (default 500 ms, 0 = never), only for the displays that are visible (not on another page, group or tab). Values next to each other in the ECU's memory are read with one request.
- Parameters: type a value and press Enter. XCP-Ray writes it and reads it back. Outside the limits of the A2L it asks first: Write anyway (only the data type limits), Write limited value (the nearest limit) or Cancel; the same for values typed into the curve and map editors. "Don't ask again" (File > Settings) writes the limited value without asking. + and - stop at the limits. Parameters with texts (enumerations) offer the texts in a list.
- Measurements can be overwritten the same way: directly when the A2L marks them
READ_WRITE, otherwise after "Allow writing" in the row menu (the field is tinted). The ECU may compute a new value at once. - Bus signals (DBC/LDF) of a frame the restbus simulation sends (ticked in the restbus display) are values you set: type a value (number or text of the value table) and press Enter, use
+/-, Space for a single bit or a list for a value table, exactly as in the restbus display. The row shows the value set (the frame is sent with it while the simulation runs), also when the other rows show the values at the scope cursor of a stopped measurement; a step is one raw step of the signal. Signals of the other frames are measured values from the bus and cannot be changed here (the tooltip says why); neither can a signal that the script function of the frame sets at every transmission (counter, CRC). - A decimal comma works like a point:
1,5is written as1.5. - Step by step: select rows (or point at one with the mouse) and press
+or-: the value changes by its step, with Shift by 10 steps; in the field of a value (nothing typed yet) the arrow keys Up and Down do the same. The step is STEP_SIZE of the A2L, else one step of the raw value (e.g. 0.01 for a factor of 0.01), else the last digit of the format (%8.3: 0.001). Texts go to the next or previous text. The value is read from the ECU first and kept within the limits; a key held down writes as fast as the ECU answers. - Space toggles a boolean: a parameter with two texts (e.g. OFF/ON) or an integer from 0 to 1.
- Row size: Ctrl
+and Ctrl-make the selected rows larger or smaller (up to 4 times), Ctrl0normal; saved in the project. - Show value as (row menu): Physical, or the raw value in memory as decimal, hexadecimal or binary, e.g. to check bits and counters. Integers are shown in the width of their type (or of their BIT_MASK), negative ones in two's complement for hex and binary (
0xFFFEfor -2); floating-point values as their IEEE bits. Also offline at the cursor; saved in the project. Values are still typed in physical units. Time (d hh:mm:ss) reads the physical value as seconds and shows it as days, hours, minutes and seconds (1 d 02:03:04,00:12:05; below one hour with milliseconds,00:00:12.345). Texts without a number (e.g. enums) stay as they are. - Click a name to select rows (Ctrl/Shift+click: several); right click: color, Increase, Decrease, Toggle (only when a selected row can be changed), Show value as, Row size, remove, allow writing. The row color is shown exactly as chosen (also a custom color, which applies while you edit it); the text turns black or white, whichever is easier to read, also in the input fields of values that can be written (their field is tinted).
- Drag rows by their name into another value display to move them (Ctrl while dropping: copy), onto a row to insert them before it, or into a scope.
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).
- Double-click the notes (or "Edit text" in the menu of the tab) to edit the text; Esc or a click elsewhere shows it formatted again.
- The text is Markdown:
#,##,###headings,-bullet and1.numbered lists,**bold**, code between backquotes, code blocks between two lines of three backquotes, and tables (| a | b |with a| --- | --- |line under the header). - Text color and Background in the menu of the tab: a choice of colors, a custom one, or Default. With a text color, headings and bold text take it as well.
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).
- The plot shows the values over the axis points. Drag a point up or down: the value is written when you release the mouse and read back. Values are kept within the limits of the A2L.
- The operating point of the input quantity of the axis is marked while measuring.
- The table below holds axis points and values; type a value and press Enter.
- "Move axis points": drag the points sideways, or type in the x column. Axis points stay strictly ascending and within the axis limits. With a shared axis (COM_AXIS) all curves using it change; axis points fixed in the A2L (FIX_AXIS) cannot be moved.
- Computed axes cannot be moved either: a curve axis (CURVE_AXIS) shows the inputs at which its reference curve (CURVE_AXIS_REF) gives the indexes 0, 1, 2 ...; change the reference curve to move them. A rescale axis (RES_AXIS) comes from the rescale pairs of its AXIS_PTS in the ECU. Both are read again with "Read".
- "Read" reads the curve again; "Undo changes" writes the values and axis points read when the editor was opened.
Map editor
Opens for a CHARACTERISTIC of type MAP: signal browser "Open map editor", or drag the map onto any display, as with curves.
- Heat map or 3D: the heat map colors the cells by value (with the values in the cells when there is room); the 3D view shows the surface. In 3D, drag to rotate, Shift+drag or right drag to pan, wheel to zoom. Editing is done in the table and the heat map.
- The operating point of both input quantities is marked while measuring, in the table its row and column are highlighted.
- Table: x axis points as the header row, y axis points as the first column.
- Select cells: click, Ctrl+click (add), Shift+click (rectangle), drag in the table, click in the heat map; a click on an axis point selects its column or row; "All", "Clear selection".
- Change the selection: type a value, then "Set" (Enter), "Add" or "Add %" (e.g. 5 or -10); "Smooth" makes each selected value the mean of itself and its neighbours. A double click on a cell types a single value.
- Results are kept within the limits of the A2L (a note in the log). The values are written at once and read back. "Undo changes" writes the values read when the editor was opened.
- Axis points of maps cannot be changed yet. Curve axes (CURVE_AXIS) and rescale axes (RES_AXIS) are shown as computed, as in the curve editor.
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:
- The tick in front of a frame simulates it; simulated frames are listed first. "Nodes..." ticks all frames of a node (the transmitter in the DBC) at once. "Simulated only" hides the others; the field on the right filters frames and signals.
- Cycle ms: the cycle from the DBC (
GenMsgCycleTime), changeable. 0 = the frame is sent only when one of its values changes, or with "Send". - Open a frame for its signals. Drag the value field with the mouse (Shift: faster, Alt: slower), or Ctrl+click it to type a value. Signals with a value table have a list, single bits a check box. Values are rounded to the resolution of the signal and kept within its range; Data shows the bytes sent. A multiplexed signal is only in the frame while the multiplexor has its value (otherwise it is grey).
- Before you change a value a signal has its start value from the DBC (
GenSigStartValue), else 0. - Start sends the ticked frames, Stop ends it. The simulation never starts by itself (also not when a project is opened). It runs independently of measurements and stops when the bus is disconnected or switched off. A frame that cannot be sent is counted red; the message above the table says why (often: no other node on the bus acknowledges the frames).
- The sent frames are also decoded like received ones: measure the bus as usual, and the simulated values appear in scopes, value displays and the recording.
- Ticked frames, changed cycles and values are saved in the project.
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).
- "Script..." in the toolbar of the restbus display: New... writes a script with examples, and
xcpray.d.luanext to it; Choose... takes an existing.luafile; Edit opens it in the editor of the system; Reload, Remove. The path is saved in the project (relative to it); a project export takes the script along (folderscripts/). - Once a script is set, the column Script chooses the function of each frame ("-" = none).
- Edit the script in any editor and save it: XCP-Ray loads it again within a second (the log says so). With VS Code and the extension "Lua" (lua-language-server) the editor completes the names of XCP-Ray from
xcpray.d.lua. - A function gets the frame with the bytes built from the signal values and a table
stateof this frame, which keeps its contents between the calls (e.g. the counter) until the script is loaded again:
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 script | Meaning |
|---|---|
frame[i] | byte i (0 = first byte, as in the DBC), read and write, 0..255 |
#frame, frame.name, frame.id | length, 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 false | skip 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 |
- The script runs in a sandbox: no files, no programs, no network (no
io,os,require,load); source text only. A call that runs too long (an endless loop) is stopped. - If the script cannot be loaded, the "Script" button is red and its tooltip shows the error with file and line. If a function fails, its frame is not sent (counted red); the Script column is red, its tooltip and the log show the error.
- Signals the function changed show the value sent last in color in the raw column (the value field keeps your value, which the function gets).
examples/restbus-scriptsin the package has building blocks to copy from (README.txt there): counters, CRC8 with a data ID before or after the data or one per counter value, CRC16 and CRC32 with length and counter (CAN FD), counter and CRC found by the signal names, simple sums and XOR. The end-to-end protections of AUTOSAR and of the vehicle manufacturers are combinations of these; take the parameters from the specification of your protection.statebelongs to the frame: give each frame one function.
Node logic. Inside the functions the script also reaches the rest of the bus:
| In the script | Meaning |
|---|---|
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
- A frame without cycle goes out as soon as
:setchanges one of its values or:send()is called - within about a millisecond after the frame that triggered it (CAN). - Values, activation and cycle the script changes appear in the restbus display and the value display; they do not mark the project as changed (but are saved with it when you save).
on_receiveruns in the receive thread of the bus (also for every frame of a busy bus): keep it short. Frames the PC sends itself do not reach it.examples/restbus-scripts/node_logic.luahas building blocks: a sine wave and a sequence over time, a frame that drops out, a frame sent only while another node is alive, a gateway and an answer withon_receive.
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.
- Frames: every frame by time (seconds since the bus was connected), with identifier, name from the DBC/LDF, length, data bytes and info (Tx; CAN FD, BRS, ESI, RTR; on LIN errors such as "no response" or "checksum error" in red). "Newest at the top" turns the order around. "Auto-scroll" follows the newest frame; scrolling by hand (wheel, scroll bar, Page Up/Down) switches it off, and the view then stays on the frames you are looking at while new ones come. "Changed only" lists only frames whose data (or length, or LIN error) differ from the frame before with the same identifier; the first frame of each identifier is always listed.
- Identifiers: one row per identifier with its last frame, "as received" (in the order the identifiers were first seen) or "by identifier". The bytes (and the length) that changed with the last change are shown in red and stay red until a frame with another change comes, also while the same data keep coming; Count is the number of frames, Cycle the time since the frame before.
- Open a frame of the DBC/LDF (the arrow in front) for its signals: name and value (with unit or the text of the value table), the bytes the signal occupies (the others shown as
..), its bits, byte order and raw value. In the identifier view a value that changed with the last change is shown in red. A multiplexed signal is only listed while the multiplexor has its value. - Pause holds the list to look at it (open frames, scroll) while the frames are still logged; Continue shows them as they come again. Clear empties the log of the bus.
- The log is kept in memory only (not in the recording): the newest 100,000 frames per bus (File > Settings > Bus log), the oldest go. It stays after a measurement and after Disconnect and starts anew when the bus is connected again.
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.
- Each measurement is sampled in a DAQ event of the ECU: from the A2L, the ECU's default event, or as chosen in the signal browser (right click > DAQ event). From the A2L: the fixed event (
FIXED_EVENT_LIST), else the first proposed one (DEFAULT_EVENT_LIST). Variables that the ECU addresses relative to an event (XCPlite: local variables, address extensions 2 and 3) can only be measured in that event. - Before the start XCP-Ray estimates the bus load; above "Max. bus load" the start is refused with a note in the log. On CAN FD the data phase counts at the data bitrate; when it is not known (not given for the ECU or a bus on the channel, not in the A2L), at the nominal bitrate, which gives a higher load: enter the data bitrate for a closer estimate.
- Lost data (missing ODTs, gaps in the time stamps, receive overruns) is counted in the toolbar and the Status tab and shown as gaps in the scopes.
- After a reset or a lost connection an ECU reconnects and restarts its measurement when its Reconnect setting allows it; the other ECUs keep measuring.
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:
- Store in the ECU (faster start): the DAQ lists of the running measurement are stored. Every later start with the same signals (same events, same addresses) uses them without configuring; the log says "DAQ configuration stored in the ECU". Other signals are configured as usual.
- Store with RESUME (started at power-up): in addition the ECU starts these lists itself at every power-up or reset, before XCP-Ray connects (XCP RESUME mode). A measurement that runs goes on through a reset of the ECU: the data of the first milliseconds after the boot is recorded, the connection is made again in the background ("the ECU restarted in RESUME mode"). Mind that the ECU then sends this data on the bus after every power-up, also without XCP-Ray.
- Show writes what the ECU has stored into the log, Clear removes it.
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):
| Column | Meaning |
|---|---|
| On | the trigger is checked in the next measurement |
| Name | shown in the log, the markers and the file names |
| Signal | a measurement of an ECU or a signal of a bus; it is measured also if no display shows it |
| Condition | rising above, falling below, crossing (both), leaving the range (two values), equal to |
| Value | the threshold in the unit of the signal (the range: lower and upper value) |
| Pre, Post [s] | the window before and after the hit |
| Max | at most this many hits per measurement (0 = no limit) |
| Export | after the measurement one file per hit with its window, MDF4 or CSV |
- The condition is checked at every measured value, so the time resolution is the event of the signal (e.g. 1 ms), not the screen. The first value of a measurement is no edge.
- After a hit the trigger waits until its post-trigger time is over, so a flickering signal does not fire again and again.
- Every hit is written into the recording as an event at the time of the measured value: a dashed marker with its text in the scopes, also when the recording is opened again and in an MDF4 export. The log and the list "Hits" in the dialog show it with its time since the start and its value.
- The windows are written next to the recording as
<recording>_<trigger>_<n>.mf4(or.csv), from pre-trigger to post-trigger time, with all signals of the recording. - The whole measurement is recorded as always; keeping only the windows is planned.
- The triggers are stored in the project. Changes during a measurement take effect at the next one.
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 > Save dataset > ECU (connected) reads all parameters and writes them to a
.dcmfile. Parameters that cannot be read, and kinds not supported yet (CUBOID, CUBE_4, CUBE_5), are listed in the log. - Calibration > Load dataset > ECU reads a
.dcmfile and the ECU's current values and shows a comparison: per parameter the status, the value in the ECU and in the file. Status: - *changes*: will be written (selected);
- *same*: nothing to do (hidden, "Show unchanged parameters" shows them);
- *type/conversion differ*: the data type or the conversion in the current A2L is not the one the file was saved with; selectable, then the physical value is written with the conversion of the current A2L;
- *other shape* (a value instead of a curve, another number of axis points), *out of limits*, *not in the A2L*, *read only*: cannot be written.
- Write N parameter(s) first saves the ECU's current values next to the file as
NAME.before-<time>.dcm(nothing is written if that fails), then writes the selected parameters; each one is read back. Curves and maps keep their axis points (a note shows when they differ). During a recording the load is kept in it as an event. - Files of other tools can be loaded too; without XCP-Ray's check lines (
*x1) the data type and conversion are not checked.
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.
- Calibration > Calibration pages > ECU (connected) opens a window with every segment of the ECU (address, size) and two lists: "The ECU uses" and "XCP-Ray reads and writes". A page is marked "read only" or "not for the ECU" if the ECU says so; such a page cannot be chosen for that purpose. The window stays open: the value displays show the page you chose.
- With XCP-Ray on the reference page you see the values of the firmware; writing there is refused (
ERR_WRITE_PROTECTED). With the ECU on the reference page it ignores your changes in the working page until you switch it back. - Copy page A onto page B copies all data of the segment, e.g. the reference page onto the working page: every value goes back to the one of the firmware.
- XCP-Ray starts every connection on the initial page of the XCP side; the page of the ECU stays as it was. The pages are read from the ECU; the A2L does not need to describe them. An ECU without page switching says "This ECU has no calibration pages."
- A locked ECU (see "Seed & Key") refuses page switching and copying until it is unlocked.
- Curves and maps show the values of the page XCP-Ray reads: press "Read" in their display after switching.
- The command line:
xcpray-cli pagesshows the segments,pages --ecu 0andpages --xcp 0switch (with--segment Nfor other segments),pages --copy 0 1copies, and--xcp-page 0 get NAMEreads from page 0 for one command.
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:
- Every channel group with a time channel becomes a group of the recording, with its channels as signals (names, units, comments). Sorted and unsorted files, compressed data (also transposed) and data lists are read.
- Number channels of all sizes, also bit fields and big endian. Conversions stay with the signal (linear, rational, formula, tables, value tables and value range tables with texts), so the scope shows physical values and the raw value is still there; a value range to value table is applied at the import.
- Values marked invalid in the file have no value (a gap in the scope).
- Text channels (e.g. status or error texts): each change of the text becomes an event of the recording, shown in the scopes as a dashed line with the text (
status: ENGINE RUNNING), at most 10,000 per channel. - Left out, each with a line in the log: byte array channels, other channels of variable length, arrays, channel groups without time channel. MDF 3 files are not read.
- Channels named
ECU:NAME(as the MDF4 export of XCP-Ray writes them) get their ECU back. - CAN bus logging of data loggers (e.g. CANedge, Vector loggers: channel groups with
CAN_DataFrame): XCP-Ray asks for DBC files before the import ("Decode CAN frames"), filled in with the DBC files of the CAN buses of the project. Every message of a DBC becomes a group of the recording, its signals are namedBUS:Message.Signalas in a measurement (multiplexed signals in groups of their own, a signal a short frame does not carry keeps its value). "Bus channel" takes only the frames of one channel of the logger (CAN 1, CAN 2, ...) for that DBC; "all" takes every channel. "Import without DBC" imports only the numbers of the frames (identifier, length). The log says how many frames were decoded and how many identifiers are not in the DBC files. - Files that were not finalized (a logger switched off while writing, e.g. CANedge) are read up to the end of their data; the log says that the last records may be missing.
CSV, e.g. data from a data logger, from Python or from Excel, or a CSV that XCP-Ray exported:
- The first column is the time in seconds (
[ms]or[us]in its header for those units). The other headers are the signal names;ECU:NAMEkeeps the ECU part,[unit]at the end is the unit. - The separator and the decimal mark are recognized:
,with., or;(or a tab) with,or.(German Excel). - An empty cell means "no value at this time": signals with values at the same times form a group of their own, as with signals of different rasters.
- A column with texts (e.g. ON/OFF) becomes a signal with a value table.
- Rows without a valid time, or going back in time, are skipped; the log says how many.
Export
File > Export recording (while a recording is open):
- MDF4 (.mf4): ASAM MDF 4.10, one data group per DAQ list, time in seconds. Each signal keeps its raw value with its conversion (linear, rational, tables, texts of enumerations), so MDF tools show the same physical values with units. Formulas (FORM) and rational functions with squares have no MDF equivalent: these signals contain the physical values.
- CSV (comma, point): one time column for all signals; cells of signals not sampled at a time stay empty.
- CSV for Excel, German (semicolon, comma).
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):
- Theme: Dark (default) or Light; applied at once.
- UI size: Automatic (default) follows the scale of the monitor the main window is on (e.g. 150 % in the display settings of Windows, or a HiDPI screen), or a fixed size from 50 % to 300 %. Texts, buttons, dialogs and plots grow together; at exactly 100 % the pixel-exact font is used. A2L Studio started from XCP-Ray uses the same size (
x1-a2l-studio --ui-scale PERCENT). - Check for updates at every start (default on): see "Updates, support and problem reports".
- Reopen the last project at start (default off): when no project, configuration or recording is given on the command line, the project opened or saved last is loaded.
- Project history (default on): keep the state of the project after every change (File > Project history, see "Projects").
- Recordings: in the recordings folder of each project (default), or all in one folder.
- Pack each recording into one file after the measurement (default on), with Compress the measured data (default on): the recorded values are stored compressed, typically 3 to 5 times smaller files (constant signals far more). Opening and the overview are as fast as before; zoomed in, only the visible part is decompressed. Every packed file is checked against the measured data before the folder is removed.
- Ask when a typed value is outside the limits of the A2L (default on): off, the limited value is written.
- Script interface (Python) (default off), its port, and access from other computers (see "Scripts (Python)").
- Explain when a display or page docks back (default on): the dialog that only page groups can be own windows.
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.
- File > Settings > Script interface: switch it on and choose the port (5591 by default). XCP-Ray listens on 127.0.0.1, so only programs on this computer can connect.
- Token: with every start of the interface XCP-Ray writes a new random token into the file
api-tokennext to its settings (Linux~/.config/xcpray/api-token, Windows%APPDATA%\xcpray\api-token), readable only by your user. A script must send it first; without it every call is refused. So only who may read this file can write into the ECUs, and an old token is useless after a restart. The Python library reads the file itself; else it takes the token fromXCPRAY_TOKEN, the file fromXCPRAY_TOKEN_FILE, orxcpray.connect(token=...). File > Settings shows the current token with a Copy button. - Access from other computers (File > Settings, off by default): XCP-Ray listens on 0.0.0.0, so a script on another computer can connect with the token (
xcpray.connect(host=..., token=...)). The connection is not encrypted: the token and all values go through the network in plain text. Only in trusted networks; the firewall may have to allow the port. - The Python library
xcpray(open source, MIT) is on GitHub:flmueller/xcpray-python(pip install git+https://github.com/flmueller/xcpray-python). - Writes of a script go the same way as typed values: the limits of the A2L apply, and they appear in the log and in the recording, marked "(script)".
- Buses: signals of a CAN bus with a DBC or a LIN bus with an LDF are named
BUS:Message.Signal.readdecodes the last frame of the message received on the bus (also without a measurement, while the bus is connected) and gives its age in seconds;writesets the value of the restbus simulation (a number, or a text of the value table; limited to what the signal can hold). It is sent while its frame is active and the simulation runs, whichrestbus_startandrestbus_stopswitch (Python:ray.restbus_start("BODY")). Needs the Python library 0.2.0 or newer for these two calls.
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:
- Screenshots of all windows (default on): the main window and every page group taken out, as they were when you opened the dialog.
- Log of this session (default on).
- The project with its A2L and DBC files (default off): only send it if you may; A2L and DBC files are often confidential.
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
| Key | Action |
|---|---|
| F1 | this manual |
| F5 / F6 | start / stop the measurement |
| Ctrl+N, Ctrl+O | new project, open project |
| Ctrl+S, Ctrl+Shift+S | save project, save project as |
| Ctrl+D | display names (DISPLAY_IDENTIFIER) on/off |
| C | scope cursor on/off (in a scope) |
| Left / Right | move the scope cursor to the previous / next sample |
| Ctrl+C | copy 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:
| Option | Meaning |
|---|---|
-c, --config FILE | session configuration (JSON), written by save-config |
--a2l FILE | A2L file |
-i, --interface NAME | CAN interface (can0, PCAN_USBBUS1, Vector:<channel>, J2534:<device>) |
-b, --bitrate N | CAN bitrate in bit/s, set by the tool |
--fd, --no-fd | XCP on CAN FD on or off (default: from the A2L, CAN_FD in XCP_ON_CAN) |
-d, --data-bitrate N | CAN FD data bitrate in bit/s, set by the tool |
--cmd-id ID, --res-id ID | CAN-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 MS | serial: waiting time after opening the port (default 2000) |
--no-short-upload | do not use SHORT_UPLOAD |
--seed-key COMMAND | Seed & Key: command that writes the key for a seed (see "Seed & Key") |
--xcp-page P | calibration pages: read and write page P of segment 0 for this command |
--reconnect POLICY | abort, retry or retry_forever |
--json | machine-readable output (see below) |
-v, --verbose | log details |
Commands:
| Command | Purpose |
|---|---|
info | ECU, 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 FILE | write 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:
list:{"objects": [{"kind", "name", "type", "unit", "address", "writable"}]}info: ECU, transport, resources, byte order, MAX_CTO/MAX_DTO, DAQ with its events, status.get,set:{"values": [{"name", "kind", "value", "text", "unit", "lower", "upper", "writable"}]}.valueis the physical value as a number (for texts the raw number),textthe display text.setgives the value read back after writing. A name that fails gets{"name", "error": {...}}, the others are still given.curve:name,unit, limits,axis(input quantity, unit, kind, points) andvalues.map:xandyaxes like the curve's, andvaluesas rows:values[iy][ix].save-config:{"written": FILE}.
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:
- Form for measurements, parameters, axes, conversions, tables, record layouts, groups, functions and units: the values (name, description, data type, conversion, limits, ...) and the optional keywords (address, bit mask, format, unit, byte order, ...). A value is written when the field is left; an empty optional field removes its keyword. References (conversion, record layout, table) are chosen from a list; "->" goes to the referenced block.
- Text: the A2L text of the block for anything the form does not show; "Apply" checks it.
- Rename... also changes all references in the module, Duplicate... makes a copy with a new name, Delete... lists the blocks that still refer to it, New... adds a measurement, parameter, conversion, value table, record layout, group or function from a template. "used by" lists the blocks that refer to the selected one.
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:
- Arduino (AVR), Raspberry Pi Pico and STM32 boards: XCP over the USB serial port;
Serial.print()keeps working and its text appears in the console of XCP-Ray. One library for all three:x1xcp_serial(Pico with the core of Earle Philhower, STM32 with STM32duino). - ESP32 and ESP8266: XCP on UDP/IP over Wi-Fi.
The libraries are open source (MIT) and work in the Arduino IDE and in PlatformIO:
- Arduino IDE: Tools > Manage Libraries, search for
x1xcp:x1xcp_serial(AVR, Pico, STM32),x1xcp_esp8266,x1xcp_esp32. File > Examples shows an example for each. - PlatformIO:
lib_deps = https://github.com/flmueller/x1xcp-serial.git(orx1xcp-esp8266,x1xcp-esp32). - Downloads of the website: each kit also contains
x1-elf2a2lfor Linux and Windows.
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):
- PlatformIO: a script of the library makes it after every build.
- Arduino IDE: Sketch > Export Compiled Binary writes
build/<board>/<sketch>.ino.elfinto the sketch folder (Arduino IDE 2); thenx1-elf2a2l -v variables.json -o sketch.a2l build/<board>/<sketch>.ino.elf. For AVR boards give each variable its"type"in the list (see "x1-elf2a2l"); the Pico needs nothing extra; for STM32 boards choose Tools > Debug symbols and core logs > "Symbols Enabled (-g)".
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.
- A2L: XCPlite either writes the A2L itself at run time (on Linux etc.) or
xcpclientof XCPlite makes it from the ELF file. Both use structures (see "Structures in the A2L") and put the EPK in the A2L, which XCP-Ray checks after connecting. - Calibration: each calibration segment has a working page (RAM) and a reference page (defaults, read only). Calibration > Calibration pages switches the page the ECU uses and copies pages, e.g. the reference page to the working page to reset the parameters.
- Local variables: XCPlite measures variables on the stack of a task, or copies of them, in the event of the function (address extensions 2 and 3). XCP-Ray takes the event from the A2L.
- Text messages:
XcpPrint("...")in the firmware appears in the log of XCP-Ray with the name of the ECU ("ECU texts only" in the log shows only those).
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.
- No answer on CAN: check the bitrate, the CAN-IDs (CMD and RES are often swapped), the termination of the bus, and that no other program holds the channel. An ECU on CAN FD does not answer classic CAN and the other way round: set "CAN FD" in the ECU dialog as the ECU uses it.
- Linux: the bitrate cannot be set (missing right): grant
CAP_NET_ADMIN(see "Linux: rights for CAN"), or set the bitrate outside XCP-Ray and leave the field empty. - vcan0 does not exist: it disappears after a reboot; create it again (see "Quick start").
- TCP: "XCP on TCP/IP" needs an ECU that listens on the port; "cannot connect" means nobody answers (wrong address or port, firewall). After a lost connection XCP-Ray connects again with the next command, so "Reconnect" (retry) works as with UDP.
- UDP: the ECU and the computer must be in the same network; a firewall may block the answers (Windows asks once when a program listens).
- Serial: only one program may use the port; close the serial monitor of the IDE. If the first commands time out, increase the reset delay.
- A value cannot be written although it is not locked: XCP-Ray may be on a read-only page (Calibration > Calibration pages).
- Calibration or measurement is refused with `ERR_ACCESS_LOCKED`: the ECU locks the resource; set a Seed & Key command (see "Seed & Key") and read the log after the connect.
- Wrong values: the A2L file must match the firmware (addresses change with every build).
x1-elf2a2l --updateorx1-a2l-studiobring an A2L up to date.
Measurement problems
- Bus load too high: measure fewer signals, use slower events, or raise "Max. bus load".
- Lost ODTs: the ECU or the bus cannot keep up; measure fewer signals in fast events.
- A value cannot be written: it is read-only in the A2L, outside its limits, or (for measurements) not released with "Allow writing".