Diagnostics in Canoe
Diagnostics in Canoe
0 Diagnostics in CANoe
Documentation
VW TP 2.0 Diagnostics in CANoe
This document describes the steps necessary to use VW TP 2.0 for diagnostics in CANoe 5.1
SP2 and higher.
DiagnosticsInCANoe.doc
Table of contents
1 Introduction .................................................................................................................... 3
2 Prerequisites ..................................................................................................................3
3 Demo ............................................................................................................................... 3
4 Configuration .................................................................................................................4
5 Using the diagnostic console and fault memory window ..........................................6
6 Test modules..................................................................................................................7
7 ECU simulations ............................................................................................................9
8 CAPL callback interface for VW TP 2.0 ......................................................................10
9 Troubleshooting...........................................................................................................12
DiagnosticsInCANoe.doc
Introduction
Starting with CANoe 5.1 SP2, diagnostics on VW TP 2.0 (dynamic channel setup) is integrated
into CANoe. Therefore it is now possible to
Communicate with an ECU from a diagnostics control, i.e. the console or the fault
memory window. This allows an easy and simple access to the diagnostics functionality of
an ECU, either on the level of a standard like KWP 2000 or UDS, or based on the diagnostics definitions of a specific ECU defined in a CANdela description file (CDD).
Implement test modules easily. It is now easy to write test sequences that stimulate an ECU
and process its responses (cf. examples in this document).
Implement ECU simulations easily. In order to test the tester, CANoe can simulate an
ECU and send responses to the tester, e.g. in order to assure the reliability of the tester.
Hint:
The full documentation of the VW_TP20.DLL is available in this package too. Please refer
to VW_TP20_Documentation_eng.pdf.
Prerequisites
Nodelayer DLL VW_TP20.DLL version 1.5.26 or higher. This DLL is available in the
VAG Add-on packet 1.10.
Demo
In this add-on package, you will find the demo VWKWPSim. Please try the following configurations:
KWPSim.cfg: In this configuration, only the ECU simulation is included. You can access
that simulation from the diagnostics controls, i.e. the console and the fault memory window. Note the ECU panel that allows to set ECU parameters and behavior.
and a tester node simulation. It is controlled via a tester control panel.
Note that only the test case or the tester simulation can be active at a time; this is due to the
fact that the VW TP 2.0 is connection oriented.
DiagnosticsInCANoe.doc
Configuration
After installation of the node layer DLL (i.e. VW_TP20.DLL has to be located in CANoes exec32
directory), it is possible to configure the VW TP 2.0 settings for a diagnostics description in CANoe:
Configure Diagnostics/ISO TP Observer Configure Assignments
It is now possible to select the interface setting VWTP 2.0 (CANoe), which will change the tab
of the second page from Transport Layer to Transport Layer (VW TP 2.0):
Description
Address
(for tester and ECU, byte) This parameter corresponds to the destination value
in the CAN messages.
Suggested ID
(for tester and ECU) These values will be used in the dynamic connection structure as suggested CAN ids for the communication.
[0; 15] Number of data frames that are transmitted before an ACK frame has to
be send by the receiver.
Segment size
Maximum length of a segment (in byte), where 0 means that segments may have
any length.
T1, T3
DiagnosticsInCANoe.doc
Note that here the coded timer value byte has to be given:
bit 7,6 select the time base, (0,0) for 100s, (0,1) 1ms, (1,0) 10ms, (1,1) 100ms).
Example: Using the following parameters, see the corresponding message trace.
Parameter
Value
Trace
Address (Tester)
00
Address (ECU)
05
Time
ID (Tester)
2fc
6.587660
200
05 c0 fc 12 00 03 01
ID (ECU)
300
6.587890
205
00 d0 00 03 fc 02 01
Application type
01
6.588120
2fc
a0 02 4a ff 54 ff
Block size
02
6.588400
300
a1 02 68 ff 54 ff
Segment size
6.608350
2fc
10 00 02 1a 00
T1
4a
6.608510
300
b1
6.628440
300
20 00 66 5a 00 41 42 43
T2
54
6.648490
300
01 44 45 46 47 48 49 4a
6.648630
2fc
b2
ID
DLC Data
...
Notes:
These settings are stored in the CANoe configuration file, and not taken from the CDD file!
DiagnosticsInCANoe.doc
Assign the CDD to a bus (or even a bus node). After closing the dialogs, the diagnostics console
and the fault memory window will open.
Once the measurement is started, it is possible to open a communication channel to the ECU by
pressing the TP on button on the diagnostics window, i.e. the transport protocol is activated. You
can then select requests on the console and send them to the ECU; the responses will be displayed
in the console windows trace section. Note that the channel is opened automatically if necessary,
when a request is sent to the ECU.
The communication channel can be closed by pressing TP off on the diagnostics console. It can
be reopened any time.
Notes:
The fault memory window is only able to interpret the DTCs returned by the ECU if they
are defined in the CDD.
Please note that the value for the P2 timeout on the configuration page
Configure Diagnostics/ISO TP Observer Configure Diagnostics Layer
determines whether a response is considered to be in time. If the ECU responds to a request, but the console still reports no response received, check this value.
DiagnosticsInCANoe.doc
Test modules
Test modules in CANoe have the distinction of departing from the strictly event oriented paradigm.
It is possible to call a TestWaitFor function in a test case, meaning that CANoe will stop executing the test case and process other events. This allows the implementation of sequential tests
without having to implement a state machine.
In order to implement a VW TP 2.0 diagnostics test case in CANoe,
Configure a CDD (see above): use VW TP 2.0, assign the CDD to a bus (not a network, i.e.
Bus, not Bus::*) or simulation node (e.g. Bus::Node), and enter the TP parameters.
Add a MainTest routine and test cases, and adapt the ECU qualifier used in DiagSetTarget. Here are some examples:
// -----------------------------------------------------------------------void MainTest()
{
DiagSetTarget( "VWTPECU");
// Enter the ECU qualifier here!
SimpleTest();
// Shutdown connection.
CANdelaLibCloseChannel("VWTPECU");
}
// -----------------------------------------------------------------------// This test case tries to unlock the ECU by sending a key to the ECU.
testcase SimpleTest ()
{
diagRequest SecurityAccess::SecurityAccess::Process reqSA;
byte data[10]; // buffer for seed and key parameter
DWORD seed;
// aux variable for computation
DiagSetParameter( reqSA, "accessMode", 3);
DiagSetParameterRaw( reqSA, "key", data, 0);
DiagSendRequest( reqSA);
// Request seed
// cut optional parameter (length 0)
DiagnosticsInCANoe.doc
{
// positive response
write( "Security Access successful!");
} else
{
write( "Received negative response 0x%02x! Aborting.",
diagGetLastResponseCode(reqSA));
return;
}
}
}
Tip:
If you implement the generic CAPL callback interface (cf. section 7), you can access the
transport layer directly, e.g. for tests on transport protocol level.
In addition, configure the test module (context menu Configuration) to use the
VW_TP20.DLL: on the page Modules, assign the VW_TP20.DLL. Alternatively, you can
name the test module and enter a node of the same name in a database assigned to the bus.
Then you have to set the attribute NodeLayerModules to the value VW_TP20.DLL for
this node (please refer to the DLL documentation, VW_TP20_Documentation_eng.pdf).
You have to add the code for the CAPL callback interface for VW TP 2.0 to the node.
You have to make sure that the test case starts only when the channel has been established.
You can do that by using the suggested text event gSetupEvent for synchronization.
// -----------------------------------------------------------------------void MainTest()
{
DiagSetTarget( "VWTPECU");
// Enter the ECU qualifier here!
testWaitForTextEvent(gSetupEvent, 5000); // text event defined in sample interface
TestWaitForTimeout( 200);
SimpleTest();
// Shutdown connection.
Disconnect();
}
// -----------------------------------------------------------------------testcase Disconnect()
{
VWTP2_DisConnectReq();
testWaitForTextEvent(gSetupEvent, 5000);
}
DiagnosticsInCANoe.doc
ECU simulations
In order to simulate an ECU in a CAPL program, the following steps have to be taken:
From the nodes context menu, assign a node defined in a database of the simulation to the
simulation node. This step is necessary to make the node accessible in the diagnostics description configuration dialog, i.e. there the simulation node name will be presented.
Make sure that the VW_TP20.DLL module is assigned to the node. The easiest way is to assign the node via the database attribute NodeLayerModules.
Configure a CANdela diagnostics description (see above). You can use a standard CDD or
a CDD defined for a concrete ECU.
Set the Interface to VWTP 2.0 (CANoe). This is only possible if the TP node layer DLL
is installed!
Enter the VW TP 2.0 parameters on the second page of the configuration dialog. You may
also adapt the diagnostics layer parameters.
Include the generic CAPL callback interface code (cf. section 8) in the .can file.
on diagRequest SecurityAccess::SecurityAccess::Process
{
BYTE data[4];
DWORD sSeed = 357912;
DWORD value;
diagResponse this resp;
// Retrieve the parameters from the request.
switch( DiagGetParameter( this, "accessMode"))
{
case 3: // Send seed
DiagSetParameter( resp, "accessMode", 3);
data[0] = sSeed >> 24;
data[1] = sSeed >> 16;
data[2] = sSeed >> 8;
data[3] = sSeed;
DiagSetParameterRaw( resp, "data", data, 4);
DiagSendResponse( resp);
return;
case 4: // Send key;
DiagGetParameterRaw( this, "key", data, 4);
value = ((data[0] * 256 + data[1]) * 256 + data[2]) * 256 + data[3];
if( value - sSeed == 12345)
{
DiagSetParameter( resp, "accessMode", 4);
data[0] = 0x34; // security access allowed
DiagSetParameterRaw( resp, "data", data, 1);
DiagSendResponse( resp);
return;
}
DiagSendNegativeResponse(this, 0x35);
// invalid key
return;
default:
DiagSendNegativeResponse(this, 0x12);
};
// Not supported
DiagnosticsInCANoe.doc
10
This is a sample implementation of the generic CAPL callback interface providing the connection
between the diagnostics and the TP layer in a tester module or ECU simulation. It is recommended
to adapt the following variables:
gECU: This is the name of the node that will be reported in the write window. Choose an
individual value here, otherwise the write window output will be difficult to distinguish.
gSegmentInterval: This value determines the minimum distance between the sending of
segments in ms. Note that the transport protocol uses a minimum message separation time
that limits this value.
// -----------------------------------------------------------------------variables
{
// --- Tester node:
char gECU[10] = "Tester";
// For debugging output.
char gSetupEvent[20] = "VWTP20_SetupEvent"; // For synchronization CAPL/TP
/* --- ECU node:
char gECU[10] = "<ECU>";
// For debugging output.
char gSetupEvent[20] = "";
// No synchronization in ECU!
*/
long gChannelState = 0;
// Not open
DWORD gSegmentInterval = 5;
// time between sending of segments
BYTE gTargetAddr = 0;
BYTE gAppType = 0;
}
// -----------------------------------------------------------------------VWTP2_DataInd( long count)
{
/* This function gets the number of data bytes received */
byte receivedData[4096];
DWORD dataLen;
VWTP2_GetRxData( receivedData, count);
dataLen = ((receivedData[0] & 0xF) * 256) + receivedData[1];
writeDbgLevel(1,"%s: VWTP2_DataInd( %d) -> %d bytes", gECU, count, dataLen);
Diag_DataInd( receivedData, count, 0);
}
// -----------------------------------------------------------------------VWTP2_DataCon( long count)
{
/* This function gets the number of bytes succsessfully sent */
writeDbgLevel(1,"%s: VWTP2_DataCon", gECU);
Diag_DataCon( count);
}
// -----------------------------------------------------------------------VWTP2_ErrorInd( int error)
{
/* This function gets error indications */
writeDbgLevel(1,"%s: VWTP2_ErrorInd(%d)", gECU, error);
Diag_ErrorInd( error);
}
// -----------------------------------------------------------------------void VWTP2_DisConnectInd(long reason)
{
writeDbgLevel(1, "%s: VWTP2_DisConnectInd(%d)", gECU, reason);
Diag_ClosedChannelInd();
// Tell CANoe that the channel is closed.
gChannelState = 0;
// Disconnect succeeded.
if( gSetupEvent[0])
// Using events?
testSupplyTextEvent(gSetupEvent);
// Trigger waiting test case.
DiagnosticsInCANoe.doc
11
}
// -----------------------------------------------------------------------VWTP2_SetupCon(void)
{
writeDbgLevel(1, "%s: VWTP2_SetupCon()", gECU);
gChannelState = 2;
// channel open.
Diag_SetupChannelCon();
// Tell CANoe that the channel is open.
if( gSetupEvent[0])
// Using events?
testSupplyTextEvent(gSetupEvent);
// Trigger waiting test case.
}
// -----------------------------------------------------------------------_Diag_DataRequest( BYTE data[], DWORD count, long furtherSegments)
{
writeDbgLevel(1, "%s: DataRequest %d byte: %02x %02x %02x ...",
gECU, count, data[0], data[1], data[2]);
VWTP2_DataReq(data, count);
}
// -----------------------------------------------------------------------_Diag_SetChannelParameters()
{
writeDbgLevel(1, "%s: _Diag_SetChannelParameters", gECU);
write( "CANoe TP parameters(hex): ECU Addr %x, target Addr %x, TxId %x, RxId %x",
DiagGetCommParameter( "CANoe.EcuAddr"),
DiagGetCommParameter( "CANoe.TgtAddr"),
DiagGetCommParameter( "CANoe.TxId"),
DiagGetCommParameter( "CANoe.RxId"));
write( "(continued) AppType %x, SegmentSize %x, Blocksize %x, T1 %x, T3 %x",
DiagGetCommParameter( "CANoe.ApplicationType"),
DiagGetCommParameter( "CANoe.SegmentSize"),
DiagGetCommParameter( "CANoe.Blocksize"),
DiagGetCommParameter( "CANoe.T1"),
DiagGetCommParameter( "CANoe.T3"));
gAppType = DiagGetCommParameter( "CANoe.ApplicationType");
gTargetAddr = DiagGetCommParameter( "CANoe.TgtAddr");
VWTP2_SetAppType( gAppType);
VWTP2_SetRxId(
DiagGetCommParameter( "CANoe.RxId"));
VWTP2_SetTxId(
DiagGetCommParameter( "CANoe.TxId"));
VWTP2_SetECU(
DiagGetCommParameter( "CANoe.EcuAddr"));
VWTP2_SetTarget( gTargetAddr);
// Initialize VW TP 2.0 style segmentation and the segment send interval.
Diag_SetDataSegmentation( 1, DiagGetCommParameter( "CANoe.SegmentSize"),
gSegmentInterval);
}
// -----------------------------------------------------------------------// This is only necessary in ECU simulations!
long VWTP2_SetupInd(void)
{
writeDbgLevel(1, "%s: VWTP2_SetupInd()", gECU);
Diag_SetupChannelCon();
// Setup successful.
return 1;
}
// -----------------------------------------------------------------------// This callback is only called in tester nodes from DiagSetTarget()
_Diag_SetupChannelReq()
{
VWTP2_ConnectReq( gTargetAddr, gAppType);
}
// -----------------------------------------------------------------------long VWTP2_ConnectCon(long aplStatus)
{
writeDbgLevel(1, "%s: VWTP2_ConnectCon(0x%02x)", gECU, aplStatus);
gChannelState = 1; // ConnectReq succeeded
return 1; // Let DLL send SetupRequest
}
DiagnosticsInCANoe.doc
12
Troubleshooting
This section collects some frequently encountered problems, their possible causes and solutions.
Problem:
Reason:
It is possible that the dynamic channel setup is not activated for the test module or
simulation node.
Solution:
If the simulation node is defined in the database, assign a value of 1 to the node attribute VWTp_Dynamic (integer) for the node (cf. VW TP 2.0 documentation).
Since no attributes can be defined for unnamed test modules, add the following definition to the VW_TP20.INI file:
[<< Default >>]
DynamicSetup=1
Problem:
The VWTP 2.0 (CANoe) interface is not available in the diagnostics description
configuration dialog, or CANoe aborts the measurement start with an error.
Reason:
Solution:
Copy the correct version of the VW_TP20.DLL (1.5.26 or higher) into CANoes
exec32 directory.
Problem:
The ECU sends a response for a request sent from the diagnostics console, but the console does not display the response, but reports No response message received!
Reason:
Solution:
Increase the P2 timeout value on the Diagnostics Layer settings page in the CDD
configuration dialog.
DiagnosticsInCANoe.doc
13
Notes
DiagnosticsInCANoe.doc