MATLAB Examples

Access XCP A2L Files

This example shows how to access information stored in A2L files for use with XCP connections. It uses a freely available XCP slave simulator from Vector and Vector Virtual CAN channels.


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 an A2L File

Open an A2L file to parse and inspect the contents and make it usable for subsequent XCP activities.

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

  A2L with properties:

                 FileName: 'XCPSim.a2l'
                 FilePath: '\\central-mi\home\jpyle\documents\MATLAB\examples\vnt-ex15095408\XCPSim.a2l'
                SlaveName: 'CPP'
        ProtocolLayerInfo: [1×1 xcp.ProtocolLayerInfo]
                  DAQInfo: [1×1 xcp.DAQInfo]
    TransportLayerCANInfo: [1×1 xcp.TransportLayerCANInfo]
    TransportLayerUDPInfo: [1×1 xcp.TransportLayerUDPInfo]
    TransportLayerTCPInfo: []
                   Events: {1×6 cell}
             Measurements: {1×45 cell}
          Characteristics: {1×16 cell}
                EventInfo: [1×6 xcp.Event]
          MeasurementInfo: [45×1 containers.Map]
       CharacteristicInfo: [16×1 containers.Map]
                   AxisXs: [1×1 containers.Map]
            RecordLayouts: [41×1 containers.Map]
             CompuMethods: [16×1 containers.Map]
                CompuTabs: [0×1 containers.Map]
               CompuVTabs: [2×1 containers.Map]

Inspect A2L Information

The properties of the A2L file object allow you to inspect the many configuration parameters contained within the file. Of special note is the Measurements property which contains the names of all available measurements for use in DAQ/STIM lists.

ans =

  1×45 cell array

  Columns 1 through 4

    {'BitSlice'}    {'BitSlice0'}    {'BitSlice1'}    {'BitSlice2'}

  Columns 5 through 8

    {'Counter_B4'}    {'Counter_B5'}    {'Counter_B6'}    {'Counter_B7'}

  Columns 9 through 12

    {'DtChannel1'}    {'FW1'}    {'KL1Output'}    {'MaxChannel1'}

  Columns 13 through 16

    {'MinChannel1'}    {'PWM'}    {'PWMFiltered'}    {'PWM_Level'}

  Columns 17 through 20

    {'ShiftByte'}    {'Shifter_B0'}    {'Shifter_B1'}    {'Shifter_B2'}

  Columns 21 through 24

    {'Shifter_B3'}    {'TestStatus'}    {'Triangle'}    {'ampl'}

  Columns 25 through 29

    {'bit12Counter'}    {'byte1'}    {'byte2'}    {'byte3'}    {'byte4'}

  Columns 30 through 33

    {'byteCounter'}    {'bytePWMFilter'}    {'channel1'}    {'channel2'}

  Columns 34 through 37

    {'channel3'}    {'dwordCounter'}    {'limit'}    {'map1InputX'}

  Columns 38 through 41

    {'map1InputY'}    {'map1Output'}    {'offset'}    {'period'}

  Columns 42 through 45

    {'sbytePWMLevel'}    {'v'}    {'vin'}    {'wordCounter'}

Query for Event Information

Use the getEventInfo command to retrieve detailed information about an event by name.

getEventInfo(a2lObj, '10 ms')
ans = 

  Event with properties:

                         Name: '10 ms'
                    Direction: 'DAQ_STIM'
                   MaxDAQList: 255
                ChannelNumber: 1
             ChannelTimeCycle: 10
              ChannelTimeUnit: 6
              ChannelPriority: 0
    ChannelTimeCycleInSeconds: 0.0100

Query for Measurement Information

Use the getMeasurementInfo command to retrieve detailed information about a measurement by name.

getMeasurementInfo(a2lObj, 'Triangle')
ans = 

  Measurement with properties:

             Resolution: 0
               Accuracy: 0
            LocDataType: 'SBYTE'
                   Name: 'Triangle'
         LongIdentifier: 'Triangle test signal used for PWM output PWM'
             ECUAddress: 4951377
    ECUAddressExtension: 0
             Conversion: [1×1 xcp.CompuMethodRational]
              Dimension: 1
             LowerLimit: -50
             UpperLimit: 50
                BitMask: []