CAPL Scripting Quickstart - Vector Informatik GmbH

Transcription

CAPL Scripting QuickstartCAPL (Communciation Access Programming Language)For CANalyzer and CANoeV0.1 2019-04-17

AgendauBefore Getting StartedVisual Sequencer (GUI Based Programming)Brief Introduction to CAPLPanel Creation and CAPLAdditional InformationContact Information2

Before Getting StartedDifference between CANalyzer and CANoeuCANoe offers significant additionalcapability beyond CANalyzer to: Stimulate the network(s) withInteraction Layer knowledge Run automated tests and generate testreports Implement automated diagnostic isEthernetMOSTFlexRayLINCAN3

Before Getting StartedCANoe Interaction LayerThe CANoe Interaction Layer (in shortCANoeIL): Provides a signal-oriented means ofaccessing the bus Map signals to their appropriate sendmessages Controls the sending of thesemessages as a function of the (OEM)Send Modelu Transmission of messages and signals isdescribed based on attributes in the databaseu CANoeIL models the transmission behaviorat run-time using those attributesu4

Before Getting StartedCAPL SupportCAPL is available in CANalyzer PRO and all versions of CANoeCANalyzer is available in three different variants:uPRO: Professional variant: full functionalityuEXP: Expert variant: supports all applications up tocomplex analysis of heterogeneous systems; does not support CAPL programsuFUN: Fundamental variant: simple applications, does notsupport CAPL, diagnostic tester and panelsDetailed information about the variants of CANalyzer is available at our website:http://www.vector.com/vi canalyzer variants en.html5

AgendaBefore Getting StarteduVisual Sequencer (GUI Based Programming)Brief Introduction to CAPLPanel Creation and CAPLAdditional InformationContact Information6

Visual Sequencer (GUI Based Programming)GeneraluAvailable in both CANalyzer PRO and EXP as well as CANoe uThe Visual Sequencer allows you to create automated command sequences with the purpose of u7Stimulating the networkControlling applicationsIn order to structure the individual steps, loops and conditional command blocks can be used, such as uIntended to allow some automation within the EXP variantif, else if, end ifEach sequence is shown in a separate window, and can be edited at any time, even while ameasurement is running.

Visual Sequencer (GUI Based Programming)Features8uSend messages (cyclically)uSet signals/variablesuIf, else, else if andrepeat commandsuWait commandsuStart/stop replayuWrite text or valuesto write window or fileuGraphical debuguAuto complete for names

Visual Sequencer (GUI Based Programming)See Sample Configuration: CAN System Demo (CANsystemdemo.cfg)9

AgendaBefore Getting StartedVisual Sequencer (GUI Based Programming)uBrief Introduction to CAPLPanel Creation and CAPLAdditional InformationContact Information10

Brief Introduction to CAPLGeneralFunctional blocks based on CAPL (Communication Access Programming Language) can be created toprogramu Network node modulesu Special evaluation programs for individual applicationsSome CAPL characteristics:u C-like programming languageu Event based, not interrupt drivenu CAPL programs are created using an integrated development environment called the CAPL Browseru Direct access to signals, system variables and diagnostic parametersu Able to link user created DLLs11

Brief Introduction to CAPLCANoeuCreating and extending simulationsuImplementing functions for analysis in the measurement setupSimulation Setup12Measurement Setup

Brief Introduction to CAPLCANalyzeruCreating simulations or reactive scriptsuImplementing functions for analysis in the measurement setupSend Loop of the Measurement Setup13Analysis Branches

Brief Introduction to CAPLCAPL BrowserEditorSymbols andBrowser TreeFunctions(List of Events)Compiler Messages14

Brief Introduction to CAPLCompilinguIn order to generate an executable program file from a CAPL program, the program must be compiledwith the CAPL compiler:uError messages are shown in the lower Message Window:When you double-click the error description, the cursor in the Text Editor automatically jumps to thepoint in the source code, where the error originated.15

Brief Introduction to CAPLExamining a CAPL Program16uAdditional CAPL files that contain generic codethat can be reused in other programsuVariables defined here are accessible throughoutthe CAPL programuMultiple pre-defined event handlers exist foryour use within CAPL. The code in this handlerwill only be executed when the event occurs.uYou can create your own functions (specialhandler) that contain related code to beexecuted frequently

Brief Introduction to CAPLAdding Event HandlersCAPL is a procedural language in which the execution of program blocks is controlled by events. Theseprogram blocks are referred to as event procedures.17

Brief Introduction to CAPLImportant Event Handlers (CAN)uuu18Start of measurementon Start{write ("Start of CANoe");}Message receivedon message 0x123{write ("CAN Message 123");}Signal changeuTime eventuKey presson signal sigTemp{write ("Signal Temperature");}on timer tmrCycle{write ("within cycle");}on key 'a'{write ("Key a pressed");}

Brief Introduction to CAPLOn Key Procedureson key 'a'// React to press of ‘a’ keyon key ' '// React to press of spacebaron key 0x20// React to press of spacebaron key F1// React to press of F1 keyon key ctrlF1219// React to press of Ctrl-F12on key PageUp// React to press of Page Up keyon key Home// React to press of Home keyon key *// React to any key press except

Brief Introduction to CAPLData Types for CANTypeNameBit ating pointfloatdouble6464Single charactercharIntegersSignedUnsigned20Per IEEEPer IEEE8Message variablefor CANmessagefor CAN messagesTime variablesfor secondsfor millisecondstimermstimerfor Timer in sfor Timer in ms

Brief Introduction to CAPLVariables in CAPLuCAPL code:int i 100;char ch 'a';float x;// Declaration and initialization of an integer STATIC VARIABLES!!// Declaration and initialization of a character// Declaration of a floating point numberwrite ("Hundred as decimal number: %d", i);write ("Hundred as hexadecimal number: %x", i);write ("Pi as floating point number: %f", pi);write ("The decimal ASCII code of %c is %d", ch, ch);write ("The value of x is %f", x);u21Results:

Brief Introduction to CAPLString Format Specifiers22SpecifierDescription"%ld","%d"decimal display"%lx","%x"hexadecimal display"%lX","%X"hexadecimal display (upper case)"%lu","%u"unsigned display"%lo","%o"octal display"%s"display a string"%g","%f"floating point display. e.g. %5.3f means, 5 digits in total (decimal point inclusive)and 3 digits after the decimal point. 5 is the minimum of digits in this case."%c"display a character"%%"display %-character"%I64d","%lld"decimal display of a 64 bit value"%I64x","%llx”hexadecimal display of a 64 bit value"%I64X","%llX"hexadecimal display of a 64 bit value (upper case)"%I64u","%llu"unsigned display of a 64 bit value"%I64o","%llo"octal display of a 64 bit value

Brief Introduction to CAPLOperatorsOperatorDescriptionExample -Addition, subtraction-*/Multiplication, division- --Increment or decrement by 1a ;Modulo division (returns integerremainder of a division)a 4 % 3;%// a is 1 Less than; less than or equal toreturns TRUE or FALSE Greater than; greater than or equal toreturns TRUE or FALSE ! Compare for equality or inequalityreturns TRUE or FALSE&&Logic ANDreturns TRUE or FALSE Logic ORreturns TRUE or FALSE!Logic NOTchanges TRUE to FALSE and vice versa&Bitwise AND1 & 70001)// yields 1 (0001 & 0111 Bitwise OR1 70111)// yields 7 (0001 0111 Bitwise complement 1// yields 14 (0001 1110) Bitwise exclusive OR (XOR)01 11 // ergibt 10Bit shift to right or left1 3 // yields 8 (0001 1000) 23// increments a by 1

AgendaBefore Getting StartedVisual Sequencer (GUI Based Programming)Brief Introduction to CAPLuPanel Creation and CAPLAdditional InformationContact Information24

Panel Creation and CAPLCreating a PaneluA signal can be mapped to each display or control as simple as drag and dropuCANalyzer display only controls for signalsDrag & Drop25

Panel Creation and CAPLCreating System Variables26uSystem Variables can besystem defined or userdefined.uThe variables can be created,saved, imported andexported.

AgendaBefore Getting StartedVisual Sequencer (GUI Based Programming)Brief Introduction to CAPLPanel Creation and CAPLuAdditional InformationContact Information27

Additional InformationOnline Help File28

AgendaBefore Getting StartedVisual Sequencer (GUI Based Programming)Brief Introduction to CAPLPanel Creation and CAPLAdditional Informationu29Contact Information

Contact InformationLooking for more information?Visit our website: http://www.vector.comSign in for a Vector training class: http://www.vector.com/vi training en.htmlNeed help with Vector tools?Contact our support team: (248) 449 – 9290 Option 2support@us.vector.comMy contact info: 30Shawn.Kaschner@vector.com

Your questions are welcome!Author:Kaschner, ShawnVector North America 2019. Vector North America Inc. All rights reserved. Any distribution or copying is subject to prior written approval by Vector. V0.1 2019-04-17

u Available in both CANalyzer PRO and EXP as well as CANoe Intended to allow some automation within the EXP variant u The Visual Sequencer allows you to create automated command sequences with the purpose of Stimulating the network Controlling applications u In order to structure the individual steps, loops and conditional command blocks can be used, such as