vds library quickstart

Upload: wolfgang-starkmann

Post on 01-Jun-2018

280 views

Category:

Documents


1 download

TRANSCRIPT

  • 8/9/2019 VDS Library QuickStart

    1/32

     

    Quickstart Guide

     VDS Library

     Version 1.0

    English

  • 8/9/2019 VDS Library QuickStart

    2/32

     

    Imprint

    Vector Informatik GmbHIngersheimer Straße 24

    D-70499 Stuttgart

    The information and data given in this user manual can be changed without prior notice. No part of this manual may be reproduced inany form or by any means without the written permission of the publisher, regardless of which method or which instruments, electronicor mechanical, are used. All technical information, drafts, etc. are liable to law of copyright protection.© Copyright 2009, Vector Informatik GmbH

     All rights reserved.80351

  • 8/9/2019 VDS Library QuickStart

    3/32

    Quickstart Guide VDS Library Introduction

    Table of contents

    1 Introduction 3 

    4 1.1 About this user manual 1.1.1 Access helps and conventions 4 

    1.1.2 Certification 5 1.1.3 Warranty 5 1.1.4 Support 5 1.1.5 Registered trademarks 5 

    2 Overview 7 

    2.1 General 8 

    2.2 Goal 8 

    2.3 Benefits 8 

    3 Quick tour 9 

    3.1 Introduction 10 

    3.2 Including Vector.Diagnostics 10 

    3.3 Retrieve the target ECU 10 

    3.4 Create a Request object 10 

    11 3.5 Synchronous sending of a request and receiving responses

     3.6 Evaluate the result of the sending 11 

    3.7 Access parameters in a request or response 11 

    12 

    3.8 Getting and setting values of diagnostic parameters 3.9 Handling parameter iterations 12 

    3.10  Handling multiplexer parameters 13 

    3.11  Disposing Object Resources 14 

    3.12  Error handling 14 

    3.13  15 Control of Tester Present request sending

    3.14  Suppress sending of positive response 15 

    4 Rules for appl ication independent scr ipts 17 

    4.1 Introduction 18 

    4.2 Restrictions 18 

    18 4.3 Reuse scripts by modularization

    5 Example script 19 

    5.1 Introduction 20 

    20 5.2 Complete script source code (C#)

     5.3 Using the script 25 5.3.1 CANape 25 5.3.2 CANoe 25 5.3.3 Indigo 25 

    6 Frequently asked quest ions: t ips and t ricks 27 

    © Vector Informatik GmbH Version 1.0 - I -

  • 8/9/2019 VDS Library QuickStart

    4/32

    Table of contents Introduction

    6.1 FAQ Overview 28 

    - II - Version 1.0 © Vector Informatik GmbH

  • 8/9/2019 VDS Library QuickStart

    5/32

    Quickstart Guide VDS Library Introduction

    1 Introduction

    In this chapter you find the following information:

    1.1   About this user manual  page 4

       Access helps and conventions

      Certification

      Warranty

      Support

      Registered trademarks

     

    © Vector Informatik GmbH Version 1.0 - 3 -

  • 8/9/2019 VDS Library QuickStart

    6/32

    Introduction Quickstart Guide VDS Library

    1.1 About this user manual

    1.1.1 Access helps and conventions

    To find informationquickly The user manual provides you the following access helps:   At the beginning of each chapter you will find a summary of the contents,

      In the header you can see in which chapter and paragraph you are ((situated)),

      In the footer you can see to which version the user manual replies,

       At the end of the user manual you will find an index, with whose help you willquickly find information.

    Conventions In the two following charts you will find the conventions used in the user manualregarding utilized spellings and symbols.

    Style Utilization

    Blocks, surface elements, window- and dialog names of thesoftware. Accentuation of warnings and advices.

    bold

    [OK]  Push buttons in brackets

    File | Save  Notation for menus and menu entries

    CANoe Legally protected proper names and side notes.

    Sour ce code File name and source code.

    Hyperlink Hyperlinks and references.

    + Notation for shortcuts.

    Symbol Utilization

    Here you can obtain supplemental information.

    This symbol calls your attention to warnings.

    Here you can find additional information.

    Here is an example that has been prepared for you.

    Step-by-step instructions provide assistance at these points.

    Instructions on editing files are found at these points.

    This symbol warns you not to edit the specified file.

    - 4 - Version 1.0 © Vector Informatik GmbH

  • 8/9/2019 VDS Library QuickStart

    7/32

    Quickstart Guide VDS Library Introduction

    1.1.2 Certification

    Certified QualityManagement System

    Vector Informatik GmbH has ISO 9001:2000 certification. The ISO standard is aglobally recognized standard from the British Standards Institution.

    1.1.3 Warranty

    Restriction ofwarranty

    We reserve the right to change the contents of the documentation and the softwarewithout notice. Vector Informatik GmbH assumes no liability for correct contents ordamages which are resulted from the usage of the user manual. We are grateful forreferences to mistakes or for suggestions for improvement to be able to offer youeven more efficient products in the future.

    1.1.4 Support

    You need support? You can get through to our hotline at the phone numbers

    +49-711-80670-200 (Germany)

    +1-248-449-9290 (USA)

    +1-800-457-5652 (USA)

    or you write an email to the

    1.1.5 Registered trademarks

    Registeredtrademarks  All trademarks mentioned in this user manual and if necessary third party registeredare absolutely subject to the conditions of each valid label right and the rights ofparticular registered proprietor. All trademarks, trade names or company names areor can be trademarks or registered trademarks of their particular proprietors. All rightswhich are not expressly allowed, are reserved. If an explicit label of trademarks,which are used in this user manual, fails, should not mean that a name is free of thirdparty rights.

      Windows, Windows Vista, Windows XP, Windows 2000 are trademarks of theMicrosoft Corporation.

    © Vector Informatik GmbH Version 1.0 - 5 -

    mailto:[email protected]:[email protected]

  • 8/9/2019 VDS Library QuickStart

    8/32

  • 8/9/2019 VDS Library QuickStart

    9/32

    Quickstart Guide VDS Library Overview

    2 Overview

    This chapter contains the following info rmation:

    2.1  General  page 8

    2.2  Goal  page 8

    2.3  Benefits  page 8

     

    © Vector Informatik GmbH Version 1.0 - 7 -

  • 8/9/2019 VDS Library QuickStart

    10/32

    Overview Quickstart Guide VDS Library

    2.1 General

     API documentation: The detailed API documentation is provided in the online-helpformat at Vector.Diagnostics.chm in the installation directory.

    2.2 Goal

    (Vector Diagnostic Scripting Library) Main Goals The VDS Library provides a way to

       Automate the execution of diagnostic sequences

      Create, configure and send diagnostic request

      Receive and interpret diagnostic responses

      Share diagnostic procedures between CANoe, CANape, CANdito and Indigo

    (starting with CANoe 7.1. SP3, CANape 8.0, CANdito 4.0, Indigo 1.0 SP2)

    2.3 Benefits

    .NET library Basing the library on .NET provides the following benefits:

       Any .NET programming environment may be used

      Full development support is provided

       Any .NET language may be used

    Concept The API was designed with these targets in mind:  Easy usage

      Focus on application of diagnostic

      Simple creation of small scripts AND potential to build complex applications

      Usage of standard .NET classes and self-made libraries is possible

    Reuse Scripts may be developed with one tester application (e.g. CANoe) and reused inevery other application (e.g. Indigo, CANape). Please refer to section 4 for details.

    - 8 - Version 1.0 © Vector Informatik GmbH

  • 8/9/2019 VDS Library QuickStart

    11/32

    Quickstart Guide VDS Library Quick tour

    3 Quick tour

    In this chapter you find the following information:

    3.1  Introduction  page 10

    3.2  Including Vector.Diagnostics  page 10

    3.3  Retrieve the target ECU  page 10

    3.4  Create a Request object  page 10

    3.5  Synchronous sending of a request and receiving responses  page 11

    3.6  Evaluate the result of the sending  page 11

    3.7   Access parameters in a request or response  page 11

    3.8  Getting and setting values of diagnostic parameters  page 12

    3.9  Handling parameter iterations  page 12

    3.10  Handling multiplexer parameters  page 13

    3.11  Disposing Object Resources  page 14

    3.12  Error handling  page 14

    3.13  Control of Tester Present request sending  page 15

    3.14  Suppress sending of positive response  page 15

     

    © Vector Informatik GmbH Version 1.0 - 9 -

  • 8/9/2019 VDS Library QuickStart

    12/32

    Quick tour Quickstart Guide VDS Library

    3.1 Introduction

    Function set at aglance

    This section introduces the content of the library with small snippets of C# code. It isnot a complete API description – please refer to the provided online help file for that.

    3.2 Including Vector.Diagnost ics

    Concept In order to use Vector Diagnostic Scripting, it is necessary to import the library intothe .NET module.

    / / I mport l i brar y def i ni t i ons

    usi ng  Vector.Diagnostics;

    Recommendation In complex applications it can be beneficial to use an alias for the namespace to

    revent name collisions and make the source of a class more obvious.p 

    / / I mpor t l i br ar y def i ni t i ons and assi gn an al i as

    usi ng Di ag =  Vector.Diagnostics;

    / / To access t he decl ar at i ons t he al i as has t o be put i n f r ont

    Diag. Diag.Ecu ecuEngi ne = Appl i cat i on. Get Ecu( "Engi ne" ) ;

    3.3 Retrieve the target ECU

    Concept In order to communicate with an ECU, a script must retrieve an ECU object from theapplication. Only diagnostic descriptions configured at the application may serve asarget.t / / Ret r i eve t he ECU wi t h t he i dent i f i er "Engi ne"

     E 

    cu ApplicationecuEngi ne = . Get Ecu( "Engi ne") ;

    3.4 Create a Request object

    Concept  At the ECU object, requests may be created using the qualifier of a diagnostic serviceefined in the diagnostic description, or by providing a valid PDU as byte array.d

     / / Cr eat e a r equest usi ng t he ser vi ce qual i f i er 

    Request  r eqReadSWV =ecuEngi ne. Cr eateRequest ( "Sof t ware_Ver si on_Read") ;

    / / Cr eat e a r equest usi ng a ( val i d) PDURequest  r eqRaw =

    ecuEngi ne. Cr eat eRequest ( new byt e[ ] { 0x10, 0x03 } ) ;

    - 10 - Version 1.0 © Vector Informatik GmbH

  • 8/9/2019 VDS Library QuickStart

    13/32

    Quickstart Guide VDS Library Quick tour

    3.5 Synchronous sending of a request and receiving responses

     A request is always in a state that allows sending it on the network configured in theapplication for its diagnostic description. The synchronous call waits until the request

    is processed completely, i.e. either all expected responses have to be received, or atimeout or an error has to occur.

    Concept

    / / Send request on t he net work and wai t f or r esponses/ t i meout

    SendResult  r esul t = r equest .  Send ( ) ;

    3.6 Evaluate the result of the sending

    Concept The send result value indicates whether sending the request succeeded, theesponses received for the request, and if the response could be processed.r 

     i f ( r esul t .  Status  == SendStat us. Communi cat i onErr or )

    {

    / / Handl e communi cat i on err or

    }

    el se i f ( r esul t .  Status  == SendStat us. Ok)

    {

    i f ( r esul t .   Response  ! = nul l )

    {

    / / Pr ocess r esponse obj ect

    Response response = r esul t .   Response;

    }

    }

    Note For diagnostic services that may receive several responses (e.g. functional requestsor certain fault memory requests), the property Responses is used to provide a list ofresponse objects.

    3.7 Access parameters in a request or response

    Concept You can retrieve a parameter at its parent object via its qualifier.

    If a parameter cannot be found, null is returned. It is the responsibility of theiagnostic script to check the return value.d

     

    / / Ret r i eve t he par amet er f r om t he r equest wi t h i t s qual i f i er

    Parameter  param1 = r equest . Get Par ameter ( "Engi neSpeed") ;

    i f ( par am1 == nul l )

    {

    / / Er r or: par amet er coul d not be f ound

    }

    © Vector Informatik GmbH Version 1.0 - 11 -

  • 8/9/2019 VDS Library QuickStart

    14/32

    Quick tour Quickstart Guide VDS Library

    Parameter hierarchy  A parameter can hold child parameters that are accessible using the Parametersroperty. Either the qualifier of the sub-parameter may be used, or its index.p

     

    / / Get t he sub- par amet er usi ng i t s qual i f i er

    Par amet er subPar am1 = par am1.   Parameters[ "MySubPar am1"] ;i f ( subPar am1 ! = nul l )

    {

    / / Get t he second par amet er f r omt he sub- par amet er l i st

    Par amet er subPar am2 = par am1.   Parameters[ 1 ] ;

    }

    3.8 Getting and setting values of diagnostic parameters

    Concept Parameters in message objects are initialized with the default values defined in thediagnostic description (when requests are created using a service qualifier), or by aPDU as raw byte array (e.g. response messages received from the ECU).

    Each parameter object has methods that give access to its value in different formats:numeric parameter can be retrieved as double value or as formatted string, e.g.a

     doubl e val ueNumer i c = param1. Value. ToDoubl e( ) ;

    st r i ng val ueSymbol i c = par am1. Value. ToStr i ng( ) ;

    You can also set the value of a (request) parameter by calling the appropriatemethod.

    If setting the parameter is not possible, false is returned by the methods. It is theresponsibility of the diagnostic script to check the return value.

    / / Try t o set t he parameter t o a numer i c val ue

    i f ( ! par am1. Val ue.  Set( 27. 3) )

    {

    / / Coul d not set t he par ameter t o t he gi ven val ue!

    }

    / / Try to set t he parameter t o a symbol i c val ue

    i f ( par am1. Val ue.  Set( " red") )

    {

    / / Set t i ng t he t ext t abl e val ue succeeded}

    3.9 Handling parameter iterations

    Concept Diagnostic services model lists of parameters using iterations. The number of iterationelements depends on its definition, e.g. an end-of-data iteration will fill up thecomplete message, while an end-marker iteration uses a specific value to indicate itsend.

    The scripting library allows direct access to the iteration and its elements at theparameter that represents it.

    - 12 - Version 1.0 © Vector Informatik GmbH

  • 8/9/2019 VDS Library QuickStart

    15/32

    Quickstart Guide VDS Library Quick tour

    / / Get t he l i st of DTCs i n t he r esponse obj ect

    Par amet er i t erParam = r esponse. Par amet er s[ "Li st Of DTCs" ] ;

    i f ( i terParam != nul l )

    {

    / / The l i st of DTCs i s avai l abl ei f ( i t er Par am. Par amet er s. Count > 0)

    {

    / / Si nce t he l i st i s not empt y, get t he f i r st DTC

    Par amet er dt c = i t er Par am. Par amet ers [ 0] . Par amet er s[ "DTC" ] ;

    }

    }

    Iterations in requests For a request parameter, it is possible to set the number of iterations by calling aunction. False is returned if this is not possible.f  

    / / Get t he par amet er t hat r epr esent s a l i stPar amet er i t er Par am = r equest . Par amet er s[ "Val ueLi st "] ;

    i f ( i terParam != nul l )

    {

    / / Modi f y t he number of i t er at i on el ement s

    i f ( i t er Par am.   SetIterationCount(4 ) )

    {

    / / Set t he val ue i n t he l ast i t er at i on

    i t er Par am. Par amet er s[ 3] . Val ue. Set ( 27) ;

    }

    }

    3.10 Handl ing mult iplexer parameters

    Concept There is a special case where the value of one parameter determines the structure ofone or more other parameters. For example, the selector parameter choses betweenseveral parameter structures that becomes active depending on its value.

    If a selector parameter is set, the parameter structure of the request may changefundamentally, causing parameters retrieved earlier to become invalid. Thereforereat caution has to be taken in this case; otherwise null parameters may be used.g

     / / Get t he mul t i pl exer par amet er and check i t s f i r st par amet er

    Paramet er mux = r equest . Get Paramet er ( "MUX" ) ;

    Par amet er f i r st Par amI nMux = mux. Par amet ers[ 0] ;

    i f ( f i r st Par amI nMux. Qual i f i er == "Str uct 1_P1")

    {

    / / . . .

    }

    / / Get t he sel ect or paramet er and change i t s val ue

    Par amet er sel ect or = r equest . Get Par amet er ( "Sel ect i on" ) ;

    sel ector. Val ue. Set ( 27) ;

    © Vector Informatik GmbH Version 1.0 - 13 -

  • 8/9/2019 VDS Library QuickStart

    16/32

    Quick tour Quickstart Guide VDS Library

    / / f i r st Par amI nMux i s no l onger val i d!

    i f ( mux. Par amet er s[ 0] . Qual i f i er == "St r uct 27_P1")

    {

    / / The f i r st par amet er i n t he mul t i pl exer i s di f f er ent now!

    }

    3.11 Disposing Object Resources

    Concept The resources that are held for messages (requests and responses) have to becleared after the according objects won’t be accessed any more. This has to be doneby calling the Di spose( )  method of such objects.

    To assure that all (of the possibly multiple) responses of a service communicationtransaction are cleared, call the Di spose( )  method of the SendResul t  object.

    Request r equest = ecuEngi ne. Cr eat eRequest ( " . . . " ) ;SendResul t sendResul t = r equest . Send( ) ;/ / Per f or m act i ons on r esponsesendResul t . Di spose( ) ; / / Free al l ocat ed r esponse r esour cesr equest . Di spose( ) ; / / Free al l ocat ed r equest r esour ces

    Recommendation  As it is a common operation for managed languages (like C#) to explicitely disposeobject resources, C# comes with an extra statement: which is built-in in the language:‘usi ng’.With this keyword one can define a scope, outside of which an object willutomatically be disposed.a

     usi ng ( Request r equest = ecuEngi ne. Cr eat eRequest ( ". . . ") )

    { usi ng ( SendResul t sendResul t = r equest . Send( ) ){

    / / Per f or m act i ons on r esponse} / / I mpl i ci t el y cal l s sendResul t . Di spose( )

    / / I mpl i c i t el y cal l s r equest . Di spose( )

    3.12 Error handling

    Concept Error handling is performed according to these rules:

      Return values are used wherever possible to indicate whether calling a methodsucceeded.

      Exceptions are only used when it is necessary to indicate a fundamental problemand the application cannot continue executing the script.

    Return values Methods return true or false to indicate success or failure. If objects are returned, nullindicates failure. The method Request.Send returns a more elaborate SendResultobject that indicates the reason for failure in more detail.

    - 14 - Version 1.0 © Vector Informatik GmbH

  • 8/9/2019 VDS Library QuickStart

    17/32

    Quickstart Guide VDS Library Quick tour

    3.13 Control of Tester Present request sending

    Concept It is possible to control the sending of Tester Present requests explicitly to keep the

    ECU in a specific diagnostic session, or let it drop to the default session after theending has been deactivated.s

     

    / / Toggl e t he sendi ng of t est er pr esent r equest s

    i f ( ecuEngi ne.   IsTesterPresentActive( ) )

    ecuEngi ne.   ActivateTesterPresent( f al se) ;

    el se

    ecuEngi ne.   ActivateTesterPresent( t rue ) ;

    3.14 Suppress sending of positive response

    Concept The UDS protocol defines the possibility to instruct the ECU to suppress the sendingof a positive response message. A flag has to be set in the request to activate thiseature.f  

    / / Set t he f l ag t o tel l t he ECU t o not send a posi t i ve r esponse r equest .   SuppressPositiveResponse  = t r ue;

    SendResul t r esul t = r equest . Send( ) ;

    / / Does not expect a response

    © Vector Informatik GmbH Version 1.0 - 15 -

  • 8/9/2019 VDS Library QuickStart

    18/32

  • 8/9/2019 VDS Library QuickStart

    19/32

    Quickstart Guide VDS Library Rules for application independent scripts

    4 Rules for application independent scripts

    In this chapter you find the following information:

    4.1  Introduction  page 18

    4.2  Restrictions  page 18

    4.3  Reuse scripts by modularization  page 18

     

    © Vector Informatik GmbH Version 1.0 - 17 -

  • 8/9/2019 VDS Library QuickStart

    20/32

    Rules for application independent scripts Quickstart Guide VDS Library

    4.1 Introduction

    Background The applications providing the VDS library have different concepts, e.g.:

      CANoe executes the scripts in a real-time context that allows no GUI elements,especially for automated ECU testing.

      CANape focuses on the calibration of ECUs.

      Indigo is a pure diagnostic tester that offers a use-case-driven GUI to applydiagnostics.

    Consequence The applications offer very different use case libraries that cannot be present in everytool, therefore great care has to be taken to use only common functionality indiagnostic scripts intended to be portable.

    4.2 Restrictions

     Allowed libraries Only libraries and methods that follow these restrictions may be used in portablescripts:

      No parts of the threading API may be used.

      No GUI operations may be used.

      Real-time processing must not be disturbed, i.e. blocking calls (e.g. for network orI/O operations, or complex XML parsing) have to be avoided.

      Garbage collection of long duration should be avoided.

    No Assemblies The scripts can only be exchanged as source code files. Compiles assemblies are notsupported for portable scripts.

    4.3 Reuse scripts by modularization

    Hint  A practical way to reuse diagnostic scripts is modularization:

      Create one module containing only the diagnostic scripts.

      Create application specific modules that import the diagnostic scripts module, anduse the application specific features (e.g. test report generation in CANoe) only inthose modules.

    - 18 - Version 1.0 © Vector Informatik GmbH

  • 8/9/2019 VDS Library QuickStart

    21/32

    Quickstart Guide VDS Library Example script

    5 Example script

    In this chapter you find the following information:

    5.1  Introduction  page 20

    5.2  Complete script source code (C#)  page 20

    5.3  Using the script  page 25

     

    © Vector Informatik GmbH Version 1.0 - 19 -

  • 8/9/2019 VDS Library QuickStart

    22/32

    Example script Quickstart Guide VDS Library

    5.1 Introduction

    Introduction The following C# script will bring an ECU in the extended session, unlock it using theseed and key algorithm, and retrieve and print the variant coding values.

    Info: Please have a look at the following sections for instructions on using the scriptin the Vector applications.

    5.2 Complete script source code (C#)

    Initialization Import the libraries needed in this script

    usi ng Di ag = Vector. Di agnost i cs; / / di agnost i c f uncti onal i t y

    usi ng Vector. Tool s; / / out put f uncti ons

    Public class Define a public class with default constructor to allow creation of an object of this typewithout additional information.

    publ i c cl ass Codi ngReader

    {

    Tool function The following function tries to create a request for the given ECU, and checks if this isossible. An error is printed to the write window and null is returned if it fails.p

     

    pr i vat e Di ag. Request Cr eat eRequest Wi t hCheck( Di ag. Ecu ecu,

    str i ng servi ceQual i f i er)

    {Di ag. Request r eq = ecu. Cr eat eRequest ( ser vi ceQual i f i er ) ;

    i f ( r eq == nul l )

    {

    Out put . Wr i t eLi ne(

    "Err or : Cannot creat e r equest f or ser vi ce "

    + ser vi ceQual i f i er ) ;

    }

    r et ur n r eq;

    }

    Tool function This function sends a request and waits for the response. If the request cannot beent or no response is received, null is returned, the received response otherwise.s

     

    pri vate Di ag. Response SendRequest Wi t hCheck(

    Di ag. Request r equest )

    {

    / / I f no request i s gi ven r et ur n i mmedi at el y

    i f ( r equest == nul l )

    r et ur n nul l ;

    / / Send t he request and wai t f or t he response

    Di ag. SendResul t r esul t = r equest . Send( ) ;

    - 20 - Version 1.0 © Vector Informatik GmbH

  • 8/9/2019 VDS Library QuickStart

    23/32

    Quickstart Guide VDS Library Example script

    / / Eval uat e t he r esul t of t he oper at i on

    i f ( r esul t . St at us != Di ag. SendSt at us. Ok)

    {

    Out put . Wr i t eLi ne( "Er r or : SendSt at us = "

    + r esul t . St at us. ToSt r i ng( ) ) ;

    }

    / / ( Not i ce t hat t hi s exampl e assumes and r equi r es t hat

    / / t he ECU r et ur ns onl y one r esponse! )

    r et ur n r esul t . Response;

    }

    Script function  A script function is any public method of the public class that does not expectrguments and returns void.a

     

    / / Read t he var i ant codi ng set t i ngs f r om t he ECU

    / / The ECU has t o be unl ocked bef ore t he ser vi ce may be

    / / execut ed, whi ch can be done i n t he ext ended sessi on onl y

    publ i c voi d ReadVar i ant Codi ng( )

    {

     Access the ECU Communication with an ECU can only be performed after the object representing it isretrieved from the application.

    / / Ret r i eve t he ECU t o communi cate wi t h

    Di ag. Ecu door = Di ag. Appl i cat i on. Get Ecu( "Door ") ;

    i f ( door == nul l )

    {

    Out put . Wr i t eLi ne( "Err or : Cannot access ' Door ' ! ") ;r et ur n;

    }

    Extended session The unlock algorithm may only be started in the “extended diagnostic session”,therefore the ECU is switched into this session. Since the positive response is of nonterest here, the “suppress positive response” flag is set at the request.i 

    / / Ent er t he extended sessi on, but do not expect a posi t i ve / / r esponse

    usi ng ( Di ag. Request r eqSt art = Cr eat eRequest Wi t hCheck(door ,

      "ExtendedDi agnost i cSessi on_Star t ") )

    {

    i f ( r eqSt art ! = nul l )

    r eqSt ar t . Suppr essPosi t i veResponse = t r ue;

    usi ng ( Di ag. Response r espSt art =SendRequest Wi t hCheck( r eqStart ) )

    {

    © Vector Informatik GmbH Version 1.0 - 21 -

  • 8/9/2019 VDS Library QuickStart

    24/32

    Example script Quickstart Guide VDS Library

    Session changeailure

    If the ECU sends a negative response, it is likely that it is in a non-default sessionlready, so only a warning is printed and the script continues.f 

     a 

    / / Check i f t he ECU sent a negat i ve r esponse

    i f ( r espSt ar t ! = nul l && ! r espSt ar t . I sPosi t i ve){

    Out put . Wr i t eLi ne("War ni ng: negat i ve r esponse r ecei ved! ") ;

    }

    }

    }

    Request seed value For the seed and key algorithm, the seed has to be requested from the ECU first. Ifthis fails, the script cannot continue and will abort with an error.

    / / Request t he seed f or t he unl ocki ng pr ocedur e

    usi ng ( Di ag. Request r eqSeed = Cr eat eRequest Wi t hCheck( door ,

    "SeedLevel 1_Request " ) )

    {

    usi ng ( Di ag. Response respSeed =SendRequest Wi t hCheck( r eqSeed) )

    {

    i f ( r espSeed == nul l | | ! r espSeed. I sPosi t i ve)

    {

    Out put . Wr i t eLi ne("Er r or: no or negat i ve r esponse recei ved f or r equest seed!Abort i ng. ") ;

    r et ur n;

    }

    Get parameters forseed and key

    The parameter representing the seed is retrieved from the response, and theparameter that holds the key is retrieved from a new request. If any of theseparameters is not accessible, the script must abort with an error.

    / / Ret r i eve seed and key parameters

    Di ag. Par amet er seedPar am =

    r espSeed. Get Par amet er ( "Secur i t ySeed" ) ;

    usi ng ( Di ag. Request r eqKey =Cr eat eRequest Wi t hCheck( door , "KeyLevel 1_Send" ) )

    {

    Di ag. Par amet er keyPar am =

    r eqKey. Get Par amet er ( "Secur i t yKey") ;

    i f ( seedPar am == nul l | | keyPar am == nul l )

    {

    Out put . Wr i t eLi ne(

    "Er r or : Seed or key par amet er not accessi bl e! " ) ;

    r et ur n;

    }

    - 22 - Version 1.0 © Vector Informatik GmbH

  • 8/9/2019 VDS Library QuickStart

    25/32

    Quickstart Guide VDS Library Example script

    Compute key value The sample ECU uses a trivial algorithm to compute the key value from the seedvalue. It is set at the key parameter immediately for sending it in the request.

    / / The sampl e ECU uses a t r i vi al al gor i t hm t o comput e / / t he key t hat can be coded easi l y

    keyParam. Val ue. Set (

    0xFFFF - ( seedPar am. Val ue. ToUI nt 32( ) & 0xFFFF) ) ;

    Send key The request containing the computed key value is sent to the ECU. The responsemust be positive to indicate that the ECU has been unlocked successfully. Otherwisehe script aborts with an error.t 

    / / Send t he key t o the ECU and check i f a posi t i ve

    / / r esponse was r ecei ved

    usi ng ( Di ag. Response respKey =SendRequest Wi t hCheck( r eqKey)

    {

    i f ( r espKey == nul l | | ! r espKey. I sPosi t i ve)

    {

    Out put . Wr i t eLi ne( "Err or : Unl ocki ng ECU f ai l ed! ") ;

      retur n;

    }

    }

    }

    }

    }

    Retrieve codingformation

    Once the ECU is unlocked, the coding information can be retrieved by sending theppropriate request.in

     a 

    / / Request t he codi ng i nf or mat i on f r om t he ECU

    usi ng ( Di ag. Request r equest = Cr eat eRequest Wi t hCheck( door ,

    "Codi ng_Read") )

    {

    usi ng ( Di ag. Response response =SendRequest Wi t hCheck( r equest ) )

    {

    i f ( r esponse == nul l | | ! r esponse. I sPosi t i ve)

    {

    Out put . Wr i t eLi ne("Er r or : Coul d not r et r i eve codi ng! ") ;

    r et ur n;

    }

    © Vector Informatik GmbH Version 1.0 - 23 -

  • 8/9/2019 VDS Library QuickStart

    26/32

    Example script Quickstart Guide VDS Library

    Output information The parameters representing the variant coding information is output as text. Since astructure is used, the structure parameter is retrieved first, and the actual informationis located in parameters that are children of the structure parameter.

    / / Out put t he i nf ormat i on about t he codi ngDi ag. Par ameter codi ngSt r uctur e =

    r esponse. Get Par amet er ( "Codi ngst r i ng" ) ;

    Out put . Wr i t eLi ne(

    "The ECU ' Door ' i s coded f or ' " +

    codi ngSt r uct ur e. Par amet er s[ "Codi ngst r i ng. Count r yType" ]

      . Val ue. ToSt r i ng( ) +

    "' as a ' " +

    codi ngSt r uct ur e. Par amet er s[ "Codi ngst r i ng. Vehi cl eType"]

    . Val ue. ToSt r i ng( ) +

    "' wi t h speci al val ue " +

    codi ngSt r uct ur e. Par amet er s[

    "Codi ngst r i ng. Speci al Adj ust ment "] . Val ue. ToSt r i ng( )

    + " . " ) ;

    }

    }

    Return to defaultsession

    In a final step, the ECU is put into the default session, locking it again.

    / / Ret ur n t he ECU t o def aul t sessi on

    usi ng ( Di ag. Request r equest = Cr eat eRequest Wi t hCheck( door ,

    "Def aul t Sessi on_St ar t ") ){

    usi ng ( Di ag. Response response =SendRequest Wi t hCheck( r equest ) )

    {

    i f ( r esponse == nul l | | ! r esponse. I sPosi t i ve){

    Out put . Wr i t eLi ne("Er r or : no or negat i ve r esponse recei ved! " ) ;

    }

    }

    }}

    }

    - 24 - Version 1.0 © Vector Informatik GmbH

  • 8/9/2019 VDS Library QuickStart

    27/32

    Quickstart Guide VDS Library Example script

    5.3 Using the script

    5.3.1 CANape

    Introduction The script can be loaded into the "UDS“ demo delivered with every CANape installation.

    Configuration Open the "Tools“ -> “Task manager…” menu dialog and go to the “.Net Scripts” tab.Press the “Insert” button and add the according file (e.g. named CodingReader.cs)containing the script.Then select the according method (e.g. "CodingReader::ReadVariantCoding“) andpress the “Select” button.

    Execution Within the Task Manager window this method now can be started using the “Start”button.

    5.3.2 CANoe

    Introduction The script can be loaded into the "UDSsim“ demo delivered with every CANoe installation.

    Configuration Open the "Macro and .NET Snippet Configuration“ dialog (Configuration|Macro…)and "Add…“ the file (e.g. named CodingReader.cs) containing the script. Aftercompilation, the .NET snippet "CodingReader::ReadVariantCoding“ is available.

    Execution From the toolbar "Macro / Snippet“, the snippet can be selected and started while themeasurement is running.

    5.3.3 Indigo

    StartupIntroduction The script can be loaded into the Indigo demo – available e.g. via the tab.

    Configuration Open the "Script Manager“ window (View|ScriptManager or toolbar button ) and load the script with "Import Script …“. The script namedCodingReader.cs is located in the folder of the Indigo installation folder.

    Execution The script can be executed via the “Script Runner” window (View|ScriptRunner ortoolbar button ).

    © Vector Informatik GmbH Version 1.0 - 25 -

  • 8/9/2019 VDS Library QuickStart

    28/32

  • 8/9/2019 VDS Library QuickStart

    29/32

    Quickstart Guide VDS Library Frequently asked questions: tips and tricks

    6 Frequently asked questions: tips and tricks

    In this chapter you find the following information:

    6.1  FAQ Overview  page 28

     

    © Vector Informatik GmbH Version 1.0 - 27 -

  • 8/9/2019 VDS Library QuickStart

    30/32

    Frequently asked questions: tips and tricks Quickstart Guide VDS Library

    6.1 FAQ Overview

    Introduction The following list is a collection of hints to make development of diagnostic scriptseasier.

    FAQ: Where do I find the qualifiers of services and parameters?

     Answer There are several ways to access the qualifiers:

      In CANdelaStudio (the “View” version is provided with everyCANape/CANoe/Indigo, e.g.) you can open a CANdela diagnostic description andsee the qualifier at the properties dialog of every object.

      The Effective ODX Viewer  (also provided with CANape/CANoe/Indigo) displaysthe content of ODX files and allows access to the “short names” that function asqualifiers.

      The diagnostic console window (provided in CANoe, CANape and CANdito) canbe configured to display the qualifiers of diagnostic services and parameters.

      The CANape “Diagnostic Object Selection” dialog (available in the “Diagnosticobjects…” context menu of the Function Editor) provides easy access to all thosequalifiers.

      The CANoe CAPL browser allows inserting service and parameter qualifiers intoCAPL programs. You can open an empty CAPL program from CANoe and copythe output of the symbolic selection dialog (opens after pressing the right mousebutton in an edit region) into your program.

      The Indigo "Script Manager“ window allows the generation of sample code for allservices of selected ECUs. This sample code can be used for copy/paste of theservices and the associated parameters.

      The Diagnostic Console window in Indigo allows to record scripts. Use the“Record” button in the toolbar to start recording. To finish recording press the“Record” button again and enter the filename.

    FAQ: Is there a simple way to perform operations on every element of a parameterlist or iteration?

     Answer  A comfortable way to perform actions on every element of a parameter list or iterationis the standard C# f oreach construct:

    / / Pr i nt t he qual i f i er s of al l chi l d par amet er

    foreach in( Par amet er par am par ent Par am. Par amet er s)

    {

    Out put . Wr i t eLi ne( par am. Qual i f i er ) ;

    }

    - 28 - Version 1.0 © Vector Informatik GmbH

  • 8/9/2019 VDS Library QuickStart

    31/32

  • 8/9/2019 VDS Library QuickStart

    32/32

     

    Get more Information!

     Visit our Website for:

    > News

    > Products

    > Demo Software

    > Support> Training Classes

    > Addresses

    www.vector-worldwide.com