This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materials including this page, select Japan from the country navigator on the bottom of this page.

XCP Dynamic DAQ Lists

This example shows how to use XCP connections to create and use dynamic data acquisition lists. It uses a freely available XCP slave simulator from Vector and Vector Virtual CAN channels. It is also recommended to run Vehicle CAN Bus Monitor in conjunction with this example.

Run a Slave Simulator

This example requires installing a free, third-party XCP implementation from Vector. The package includes an XCP slave simulator and A2L file. To install this driver, please follow these instructions:

  1. Go to and navigate to the "DOWNLOADS" page.

  2. Search for "Demos" under "Categories" and "XCP" under "Standards".

  3. Download and install the available version of "XCP Sample Implementation".

  4. In MATLAB, navigate to where you installed the sample package, and then go to .\Samples\XCPSim\CANape.

  5. The MATLAB XCP examples will use the XCPSIM.a2l file and the XCPsim.exe slave simulator. Run XCPsim.exe.

Open the A2L File

Establishing a connection to an XCP slave requires using the A2L file that describes the slave module.

a2lObj = xcpA2L('XCPSIM.a2l')
a2lObj = 

  A2L with properties:

                 FileName: 'XCPSim.a2l'
                 FilePath: [1x65 char]
                SlaveName: 'CPP'
        ProtocolLayerInfo: [1x1 struct]
                  DAQInfo: [1x1 struct]
    TransportLayerCANInfo: [1x1 struct]
                   Events: {1x6 cell}
             Measurements: {1x38 cell}

Create an XCP Channel

Create an XCP channel in order to prepare a connection to the slave.

xcpCh = xcpChannel(a2lObj, 'CAN', 'Vector', 'Virtual 1', 1)
xcpCh = 

  Channel with properties:

               SlaveName: 'CPP'
             A2LFileName: 'XCPSim.a2l'
          TransportLayer: 'CAN'
    TransportLayerDevice: [1x1 struct]
              SeedKeyDLL: []

Connect to the Slave

To make communication with the slave active, connect to it.


Create a DAQ List

Create a DAQ list using one of the events specified in the A2L and assign to it some measurements defined in the A2L file.

createMeasurementList(xcpCh, 'DAQ', '10 ms', {'Triangle', 'PWM', 'channel3'})

Start Measurements

Starting measurements begins the transmission of DAQ messages from the slave. After running for a few seconds, stop measurements.


Retrieve the Triangle Measurement Data

Receive the acquired data from the channel for each measurement.

dataTriangle = readDAQListData(xcpCh, 'Triangle');

Retrieve the PWM Measurement Data

Receive the acquired data from the channel for each measurement.

dataPWM = readDAQListData(xcpCh, 'PWM');

Retrieve the channel3 Measurement Data

Receive the acquired data from the channel for each measurement.

datachannel3 = readDAQListData(xcpCh, 'channel3');

Disconnect from the Slave

To make communication with the slave inactive, disconnect from it.

Was this topic helpful?