Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
395 views23 pages

XCP - Part 3 - Transport Layer Specification XCP On CAN - 1.0

This document specifies how the XCP protocol is transported over CAN. It defines addressing, the communication model, headers and tails, and performance limits. It also describes specific XCP on CAN commands and events, and how to interface with ASAM MCD 2MC description files.

Uploaded by

张敏健
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
395 views23 pages

XCP - Part 3 - Transport Layer Specification XCP On CAN - 1.0

This document specifies how the XCP protocol is transported over CAN. It defines addressing, the communication model, headers and tails, and performance limits. It also describes specific XCP on CAN commands and events, and how to interface with ASAM MCD 2MC description files.

Uploaded by

张敏健
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 23

XCP

Version 1.0

“The Universal Measurement and Calibration


Protocol Family”

Part 3
XCP on CAN - Transport Layer Specification

Association for Standardization of


Automation and Measuring Systems
Association for Standardization of
Automation and Measuring Systems

Association for Standardization of


Automation and Measuring Systems
Dated:2003-04-08
© ASAM e.V.
Status of Document

Date: 2003-04-08
Authors: Roel Schuermans, Vector Informatik GmbH
Rainer Zaiser, Vector Informatik GmbH
Frank Hepperle, DaimlerChrysler AG
Hans Schröter, DaimlerChrysler AG
Reiner Motz, Robert Bosch GmbH
Andreas Aberfeld, Robert Bosch GmbH
Hans-Georg Kunz, Siemens VDO Automotive AG
Thomas Tyl, Siemens VDO Automotive AG
Robert Leinfellner, dSPACE GmbH
Hendirk Amsbeck, dSPACE GmbH
Harald Styrsky, Compact Dynamics GmbH
Boris Ruoff, ETAS GmbH
Lars Wahlmann, Accurate Technologies Inc.
Version: 1.0
Doc-ID: XCP - Part 3- Transport Layer Specification
XCP on CAN -1.0
Status: Released
Type Final

Disclaimer of Warranty
Although this document was created with the utmost care it cannot be guaranteed
that it is completely free of errors or inconsistencies.
ASAM e.V. makes no representations or warranties with respect to the contents or
use of this documentation, and specifically disclaims any expressed or implied
warranties of merchantability or fitness for any particular purpose. Neither ASAM
nor the author(s) therefore accept any liability for damages or other consequences
that arise from the use of this document.
ASAM e.V. reserves the right to revise this publication and to make changes to its
content, at any time, without obligation to notify any person or entity of such
revisions or changes.

XCP -Part 3- Transport Layer Specification XCP on CAN -1.0.DOC 2


Revision History

This revision history shows only major modifications between release versions.

Date Author Filename Comments


2003-04-08 R.Schuermans Released document

XCP -Part 3- Transport Layer Specification XCP on CAN -1.0.DOC 3


Table of contents

0 Introduction ........................................................................................................6
0.1 The XCP Protocol Family .......................................................................................... 6
0.2 Documentation Overview .......................................................................................... 7
0.3 Definitions and Abbreviations ................................................................................... 8

1 The XCP Transport Layer for CAN ....................................................................9


1.1 Addressing.................................................................................................................. 9
1.2 Communication Model............................................................................................. 10
1.3 Header and Tail ........................................................................................................ 11
1.3.1 Header .............................................................................................................. 11
1.3.2 Tail ................................................................................................................... 12
1.4 The Limits of performance....................................................................................... 13

2 Specific commands for XCP on CAN..............................................................14


2.1 Get Slave CAN identifiers........................................................................................ 15
2.2 Get DAQ List CAN Identifier.................................................................................. 17
2.3 Set DAQ List CAN Identifier................................................................................... 18

3 Specific events for XCP on CAN .....................................................................19

4 Interface to ASAM MCD 2MC description file ................................................20


4.1 ASAM MCD 2MC AML for XCP on CAN............................................................. 20
4.2 IF_DATA example for XCP on CAN ...................................................................... 22

XCP -Part 3- Transport Layer Specification XCP on CAN -1.0.DOC 4


Table of diagrams:

Diagram 1 : Header and Tail for XCP on CAN........................................................................ 11


Diagram 2 : No XCP Tail if DLC = LEN (<= MAX_DLC) .................................................... 12
Diagram 3 : XCP Tail if DLC = MAX_DLC (> LEN) ............................................................ 12
Diagram 4 : Typical use of GET_SLAVE_ID modes.............................................................. 16

XCP -Part 3- Transport Layer Specification XCP on CAN -1.0.DOC 5


0 Introduction
0.1 The XCP Protocol Family

This document is based on experiences with the CAN Calibration Protocol (CCP) version 2.1 as
described in feedback from the companies Accurate Technologies Inc., Compact Dynamics GmbH,
DaimlerChrysler AG, dSPACE GmbH, ETAS GmbH, Kleinknecht Automotive GmbH, Robert Bosch
GmbH, Siemens VDO Automotive AG and Vector Informatik GmbH.
The XCP Specification documents describe an improved and generalized version of CCP.
The generalized protocol definition serves as standard for a protocol family and is called “XCP”
(Universal Measurement and Calibration Protocol).
The “X” generalizes the “various” transportation layers that are used by the members of the protocol
family e.g “XCP on CAN”, “XCP on TCP/IP”, “XCP on UDP/IP”, “XCP on USB” and so on.

XCP
CAN TCP/IP UDP/IP USB ...

XCP is not backwards compatible to an existing CCP implementation.

XCP -Part 3- Transport Layer Specification XCP on CAN -1.0.DOC 6


0.2 Documentation Overview
The XCP specification consists of 5 parts. Each part is a separate document and has the following
contents:

Part 1 “Overview” gives an overview over the XCP protocol family, the XCP features and the
fundamental protocol definitions.

Part 2 “Protocol Layer Specification” defines the generic protocol, which is independent from the
transportation layer used.

Part 3 “Transport Layer Specification” defines the way how the XCP protocol is transported by a
particular transportation layer like CAN, TCP/IP and UDP/IP.

This document describes the way how the XCP protocol is transported on CAN.

Part 4 “Interface Specification” defines the interfaces from an XCP master to an ASAM MCD 2MC
description file and for calculating Seed & Key algorithms and checksums.

Part 5 “Example Communication Sequences” gives example sequences for typical actions
performed with XCP.

Everything not explicitly mentioned in this document, should be considered as implementation specific.

XCP -Part 3- Transport Layer Specification XCP on CAN -1.0.DOC 7


0.3 Definitions and Abbreviations

The following table gives an overview about the most commonly used definitions and
abbreviations throughout this document.

Abbreviation Description
A2L File Extension for an ASAM 2MC Language File
AML ASAM 2 Meta Language
ASAM Association for Standardization of Automation and Measuring Systems
BYP BYPassing
CAL CALibration
CAN Controller Area Network
CCP Can Calibration Protocol
CMD CoMmanD
CS CheckSum
CTO Command Transfer Object
CTR CounTeR
DAQ Data AcQuisition, Data AcQuisition Packet
DTO Data Transfer Object
ECU Electronic Control Unit
ERR ERRor Packet
EV EVent Packet
LEN LENgth
MCD Measurement Calibration and Diagnostics
MTA Memory Transfer Address
ODT Object Descriptor Table
PAG PAGing
PGM ProGraMming
PID Packet IDentifier
RES command RESponse packet
SERV SERVice request packet
SPI Serial Peripheral Interface
STD STanDard
STIM Data STIMulation packet
TCP/IP Transfer Control Protocol / Internet Protocol
TS Time Stamp
UDP/IP Unified Data Protocol / Internet Protocol
USB Universal Serial Bus
XCP Universal Calibration Protocol

Table 1: Definitions and Abbreviations

XCP -Part 3- Transport Layer Specification XCP on CAN -1.0.DOC 8


1 The XCP Transport Layer for CAN

1.1 Addressing

The master can use GET_SLAVE_ID to detect all XCP slaves within a CAN network. The
master has to send GET_SLAVE_ID with the XCP Broadcast CAN identifier.

XCP on CAN uses at least two different CAN identifiers for each independent slave: one
identifier for the CMD and STIM packets and one identifier for the RES, ERR, EV, SERV and
DAQ packets.
The STIM CAN Identifiers may be the same as the CMD CAN Identifier or may be assigned by
the SET_DAQ_ID command.
The DAQ CAN Identifiers may be the same as the RES/ERR/EV/SERV CAN Identifier or may
be assigned by the SET_DAQ_ID command.

The assignment of CAN message identifiers to the XCP objects CMD/STIM and
RES/ERR/EV/SERV/DAQ is defined in the slave device description file (e.g. the ASAP2 format
description file), which is used to configure the master device. It is recommended that the bus
priority of the message objects be carefully determined in order to avoid injury to other real-time
communication on the bus. Also, the CMD/STIM should obtain higher priority than the
RES/ERR/EV/SERV/DAQ.

The most significant bit (of the 32-bit value) set, indicates a 29 bit CAN identifier.

XCP -Part 3- Transport Layer Specification XCP on CAN -1.0.DOC 9


1.2 Communication Model

XCP on CAN makes use of the standard communication model.


The block transfer communication model is optional.
The interleaved communication model is not allowed.

XCP -Part 3- Transport Layer Specification XCP on CAN -1.0.DOC 10


1.3 Header and Tail

XCP on CAN Message (Frame)

XCP Packet XCP Tail


XCP Header
empty for CAN PID FILL DAQ TIMESTAMP DATA Fill

Control Field Control Field


empty for CAN for CAN

Diagram 1 : Header and Tail for XCP on CAN

1.3.1 Header

For XCP on CAN there’s no Header (empty Control Field).

XCP -Part 3- Transport Layer Specification XCP on CAN -1.0.DOC 11


1.3.2 Tail

For XCP on CAN, the Tail consists of a Control Field containing optional Fill bytes.
The maximum data length of a CAN message and therefore maximum length of an XCP on
CAN message is MAX_DLC = 8.
If the length (LEN) of an XCP Packet equals MAX_DLC, the Control Field of the XCP Tail is
empty and the XCP on CAN Message is the same as the XCP Packet (DLC = LEN =
MAX_DLC).
If LEN is smaller than MAX_DLC, there’re 2 possibilities to set the DLC.
A first possibility is to set DLC = LEN. The Control Field of the XCP Tail is empty and the XCP
on CAN Message is the same as the XCP Packet.

XCP on CAN Message (Frame)

XCP Packet

XCP Tail
DLC PID .... empty
LEN

DLC = LEN Control Field


empty

Diagram 2 : No XCP Tail if DLC = LEN (<= MAX_DLC)

A second possibility is to set DLC = MAX_DLC = 8. The Control Field of the XCP Tail contains
MAX_DLC – LEN fill bytes. The contents of the FILL bytes is “don’t care”.

XCP on CAN Message (Frame)

XCP Packet XCP Tail

DLC PID .... Fill


LEN MAX_DLC - LEN
DLC =
MAX_DLC =8
MAX_DLC

Diagram 3 : XCP Tail if DLC = MAX_DLC (> LEN)

With MAX_DLC_REQUIRED, the slave can inform the master that it has to use CAN frames
with DLC = MAX_DLC = 8 when sending to the slave.

XCP -Part 3- Transport Layer Specification XCP on CAN -1.0.DOC 12


1.4 The Limits of performance

The maximum length of a CTO or a DTO packet is 8.

Name Type Representation Range of value


MAX_CTO Parameter BYTE 0x08
MAX_DTO Parameter WORD 0x0008

XCP -Part 3- Transport Layer Specification XCP on CAN -1.0.DOC 13


2 Specific commands for XCP on CAN
Table of Command Codes:

Command Code Timeout Remark


GET_SLAVE_ID 0xFF t1 optional
GET_DAQ_ID 0xFE t1 optional
SET_DAQ_ID 0xFD t1 optional

XCP -Part 3- Transport Layer Specification XCP on CAN -1.0.DOC 14


2.1 Get Slave CAN identifiers

Category CAN only, optional


Mnemonic GET_SLAVE_ID

Position Type Description


0 BYTE Command Code = TRANSPORT_LAYER_CMD = 0xF2
1 BYTE Sub Command Code = 0xFF
2 BYTE 0x58 (ASCII = X )
3 BYTE 0x43 (ASCII = C )
4 BYTE 0x50 (ASCII = P )
5 BYTE Mode
0 = identify by echo
1 = confirm by inverse echo

The master can use GET_SLAVE_ID to detect all XCP slaves within a CAN network.
At the same time, the master gets to know the CAN identifier the master has to use when
transferring CMD/STIM to a specific slave and the CAN identifier this slave uses for transferring
RES/ERR/EV/SERV/DAQ.
The master has to send GET_SLAVE_ID with the XCP Broadcast CAN identifier.
If the master sends an XCP message with the XCP Broadcast CAN identifier, all XCP slaves
that are connected to the CAN network have to respond. GET_SLAVE_ID is the only XCP
message that can be broadcasted.
A slave always has to respond to GET_SLAVE_ID, even if the slave device is not in Connected
state yet.
The slave has to send the response with the CAN identifier it uses for transferring
RES/ERR/EV/SERV/DAQ.
The master sends GET_SLAVE_ID with an Identification Pattern (ASCII for “XCP”). The master
uses this Pattern for recognizing answers from XCP slaves.
If the master sends a GET_SLAVE_ID(identify by echo), the slave has to send a response that
contains an echo of the Pattern. Additionally the slave informs the master about the CAN
identifier the master has to use when transferring CMD/STIM to this slave.

Positive Response (mode = identify by echo) :

Position Type Description


0 BYTE Packet ID: 0xFF
1 BYTE 0x58
2 BYTE 0x43
3 BYTE 0x50
4..7 DWORD CAN identifier for CMD/STIM

XCP -Part 3- Transport Layer Specification XCP on CAN -1.0.DOC 15


If the master sends a GET_SLAVE_ID(confirm by inverse echo), the slave has to send a
response that contains an inversed echo of the Pattern. Additionally the slave repeats the CAN
identifier the master has to use when transferring CMD/STIM to this slave.

Positive Response (mode = confirm by inversed echo) :

Position Type Description


0 BYTE Packet ID: 0xFF
1 BYTE 0xA7
2 BYTE 0xBC
3 BYTE 0xAF
4..7 DWORD CAN identifier for CMD/STIM

If the master sends a GET_SLAVE_ID(confirm by inverse echo), without a previous


GET_SLAVE_ID(identify by echo), the slaves will silently ignore that command.
If the master first sends a GET_SLAVE_ID(identify by echo) and then a GET_SLAVE_ID(confirm
by inversed echo), this sequence allows the master to reliably distinguish the responses of the
slaves from other communication frames on the CAN network and to reliably detect the CAN
identifier pairs for every single slave.

Master Slave
upon GET_SLAVE_ID(XCP, identify by echo)
Broadcast CAN id
slave 1 upon its
Response(XCP, CAN id for CMD/STIM) CAN id for RES/
ERR/EV/SERV/DAQ

Response(XCP, CAN id for CMD/STIM) slave 2 upon its


CAN id for RES/
ERR/EV/SERV/DAQ
upon
GET_SLAVE_ID(XCP, confirm by inversed echo)
Broadcast CAN id

Response(XCP, CAN id for CMD/STIM)


slave 1 upon its
CAN id for RES/
ERR/EV/SERV/DAQ

Response(XCP, CAN id for CMD/STIM) slave 2 upon its


CAN id for RES/
ERR/EV/SERV/DAQ

upon CONNECT
CAN id for CMD/STIM
for slave 1 slave 1 upon its
Response
CAN id for RES/
ERR/EV/SERV/DAQ
upon CONNECT
CAN id for CMD/STIM
for slave 2 slave 2 upon its
Response
CAN id for RES/
ERR/EV/SERV/DAQ

Diagram 4 : Typical use of GET_SLAVE_ID modes

XCP -Part 3- Transport Layer Specification XCP on CAN -1.0.DOC 16


2.2 Get DAQ List CAN Identifier

Category CAN only, optional


Mnemonic GET_DAQ_ID

Position Type Description


0 BYTE Command Code = TRANSPORT_LAYER_CMD = 0xF2
1 BYTE Sub Command Code = GET_DAQ_ID = 0xFE
2,3 WORD DAQ_LIST_NUMBER [0,1,...MAX_DAQ-1]

Positive Response:

Position Type Description


0 BYTE Packet ID: 0xFF
1 BYTE CAN_ID_FIXED
0 = CAN-Id can be configured
1 = CAN-Id is fixed
2,3 WORD Reserved
4..7 DWORD CAN Identifier of DTO dedicated to list number

As a default, the master transfers all DAQ lists with DIRECTION = STIM on the same CAN
Identifier as used for CMD.
Alternatively, the master may have individual CAN Identifiers (other than the one used for CMD)
for the DAQ lists with DIRECTION = STIM.

As a default, the slave transfers all DAQ lists with DIRECTION = DAQ on the same CAN
Identifier as used for RES/ERR/EV/SERV.
Alternatively, the slave may have individual CAN Identifiers (other than the one used for
RES/ERR/EV/SERV) for its DAQ lists with DIRECTION = DAQ.

With GET_DAQ_ID, the master can detect whether a DAQ list uses an individual CAN identifier
and whether this Identifier is fixed or configurable.
If the CAN Identifier is configurable, the master can configure the individual Can Identifier for
this DAQ list with SET_DAQ_ID.

XCP -Part 3- Transport Layer Specification XCP on CAN -1.0.DOC 17


2.3 Set DAQ List CAN Identifier

Category CAN only, optional


Mnemonic SET_DAQ_ID

Position Type Description


0 BYTE Command Code = TRANSPORT_LAYER_CMD = 0xF2
1 BYTE Sub Command Code = SET_DAQ_ID = 0xFD
2,3 WORD DAQ_LIST_NUMBER [0,1,...MAX_DAQ-1]
4..7 DWORD CAN Identifier of DTO dedicated to list number

The master can assign an individual CAN Identifier to a DAQ list.


If the given identifier isn’t possible, the slave returns an ERR_OUT_OF_RANGE.

XCP -Part 3- Transport Layer Specification XCP on CAN -1.0.DOC 18


3 Specific events for XCP on CAN
There are no specific events for XCP on CAN at the moment.

XCP -Part 3- Transport Layer Specification XCP on CAN -1.0.DOC 19


4 Interface to ASAM MCD 2MC description file
The following chapter describes the parameters that are specific for XCP on CAN.

4.1 ASAM MCD 2MC AML for XCP on CAN


/************************************************************************************/
/* */
/* ASAP2 meta language for XCP on CAN V1.0 */
/* */
/* 2003-03-03 */
/* */
/* Vector Informatik, Schuermans */
/* */
/* Datatypes: */
/* */
/* A2ML ASAP2 Windows description */
/* --------------------------------------------------------------------------------------------*/
/* uchar UBYTE BYTE unsigned 8 Bit */
/* char SBYTE char signed 8 Bit */
/* uint UWORD WORD unsigned integer 16 Bit */
/* int SWORD int signed integer 16 Bit */
/* ulong ULONG DWORD unsigned integer 32 Bit */
/* long SLONG LONG signed integer 32 Bit */
/* float FLOAT32_IEEE float 32 Bit */
/* */
/**************************************************************************************/
/************************ start of CAN ***********************************************/

struct CAN_Parameters { /* At MODULE */

uint; /* XCP on CAN version */


/* e.g. "1.0" = 0x0100 */

taggedstruct { /* optional */
“CAN_ID_BROADCAST” ulong; /* Auto detection CAN-ID */
/* master -> slaves */
/* Bit31= 1: extended identifier */

“CAN_ID_MASTER” ulong; /* CMD/STIM CAN-ID */


/* master -> slave */
/* Bit31= 1: extended identifier */
“CAN_ID_SLAVE” ulong; /* RES/ERR/EV/SERV/DAQ CAN-ID */
/* slave -> master */
/* Bit31= 1: extended identifier */

“BAUDRATE” ulong; /* BAUDRATE [Hz] */

"SAMPLE_POINT" uchar; /* sample point */


/* [% complete bit time] */
"SAMPLE_RATE" enum {
"SINGLE" = 1, /* 1 sample per bit */
"TRIPLE" = 3 /* 3 samples per bit */
};

XCP -Part 3- Transport Layer Specification XCP on CAN -1.0.DOC 20


"BTL_CYCLES" uchar; /* BTL_CYCLES */
/* [slots per bit time] */
"SJW" uchar; /* length synchr. segment */
/* [BTL_CYCLES] */
"SYNC_EDGE" enum {
"SINGLE" = 1, /* on falling edge only */
"DUAL" = 2 /* on falling and rising edge */
};

“MAX_DLC_REQUIRED”; /* master to slave frames */


/* always to have DLC = MAX_DLC = 8 */

(block “DAQ_LIST_CAN_ID” struct { /* At IF_DATA DAQ */

uint; /* reference to DAQ_LIST_NUMBER */

taggedstruct { /* exclusive tags */


/* either VARIABLE or FIXED */
"VARIABLE";
"FIXED" ulong; /* this DAQ_LIST always */
/* on this CAN_ID */
};

})*;

};

};/************************* end of CAN ***********************************/

XCP -Part 3- Transport Layer Specification XCP on CAN -1.0.DOC 21


4.2 IF_DATA example for XCP on CAN

/begin XCP_ON_CAN

0x0100 /* XCP on CAN version */

CAN_ID_BROADCAST 0x0100 /* Broadcast */

CAN_ID_MASTER 0x0200 /* CMD/STIM */


CAN_ID_SLAVE 0x0300 /* RES/ERR/EV/SERV/DAQ */

BAUDRATE 500000 /* BAUDRATE */

/begin DAQ_LIST_CAN_ID
0x0000 /* for DAQ_LIST 0 */
FIXED 0x310
/end DAQ_LIST_CAN_ID

/begin DAQ_LIST_CAN_ID
0x0001 /* for DAQ_LIST 1 */
FIXED 0x320
/end DAQ_LIST_CAN_ID

/begin DAQ_LIST_CAN_ID
0x0002 /* for DAQ_LIST 2 */
FIXED 0x330
/end DAQ_LIST_CAN_ID

/end XCP_ON_CAN

XCP -Part 3- Transport Layer Specification XCP on CAN -1.0.DOC 22


ASAM e. V.
Arnikastraße 2
D - 85635 Hoehenkirchen
Germany

Tel.: (+49) 8102 / 895317


Fax.: (+49) 8102 / 895310
E-mail: [email protected]
Internet: www.asam.net

XCP -Part 3- Transport Layer Specification XCP on CAN -1.0.DOC 23

You might also like