Documente Academic
Documente Profesional
Documente Cultură
R E F E R E N C E
M A N U A L
Table of Contents
TABLE OF CONTENTS
5 CAPL Programming
Programming Examples ................................................
................................................152
152
5.1 Sending an Event Message ................................................................................... 152
5.2 Sending a Periodic Message.................................................................................. 153
5.3 Sending a Conditionally Repetitive Message .......................................................... 155
Index ................................................................
.....................................................................................
.....................174
174
1 OVERVIEW OF CAPL
Node Emulation
Using the programmable version of CANalyzer, one can emulate functions a node including the
transmission of event, periodic, and conditionally periodic messages. Users can create
conversational responding messages to the reception of designated messages.
Network Emulation
Using CAPL, CANalyzer can emulate the system-level data traffic of all remaining nodes.
Node Testing
During a portion of CAN-based module development, CANalyzer can be used to test the
module’s communication behavior. Evaluation of message timing, handling of Bus Off, and other
functions is easy to accomplish.
Gateway
The programmable CANalyzer can be used as a temporary or permanent gateway (or bridge)
between different CAN buses to exchange data.
Bus Separator
Another target application is to insert CANalyzer Pro between a node to be tested and the actual
network. Such configurations can be used during system-level development to isolate behavior.
The ability to interconnect modules at different revision levels to the distributed product in order to
continue development is also another possible application.
Even though CAPL can be thought of as a procedural programming language, CAPL can also be
considered as a programming environment.
Within this programming environment a user can create, modify, and maintain CAPL programs
which can interface with a wide variety of inputs, outputs and other functions. Start-stop events,
keyboard entry events, the ability to transmit and receive CAN messages, interaction with the
serial port and parallel port, the use of timers, and the ability to interconnect to customer specific
DLLs are some of the interface choices available inside the CAPL programming environment.
Most programs are developed using the CAPL Browser which provides an easy to use “edit-
thru-compilation” development process. Even though provided as an integrated component of
CANalyzer or CANoe, the CAPL Browser application program can also be used separately.
In general, CAPL programs are simply designed to detect events and then execute the
associated event procedure.
For example, you could output the text “Start Test” to the Write window upon clicking on the start
button of CANalyzer by using the following program.
on start
{
write(“Start Test”);
}
Based on this “event causes procedural activity” technique, CAPL programs are constructed and
organized as a collection of event procedures.
The CAPL Browser is conveniently structured into different groupings of event procedures.
These so-called event procedural groups or event classes include system, CAN controller, CAN
message, timer, keyboard, and CAN error frame as shown in the CAPL event table.
CAPL EVENTS
It is important to note that the use of each message must include a definition within the global
variables. In this example we have defined the message msg1 as having a CAN identifier of
555 hex and data length code (dlc) or data size of one byte.
Note: While this example shows defining a message completely within this APL program, it is
easy to use the CANdb program (another related application program in the vector CAN tool
suite) to link a user-defined or corporate specific messaging database.
In the “keyboard” event class we insert (via the right mouse button) a new procedure for the ‘b’
key press. Don’t forget to include the single quote marks. In this on key procedure, we fix the first
byte of the can message data equal to hexadecimal AA and then use the internal CAPL function
output to transmit the message. Notice that the message name used in the output function is
identical to the name defined in the global variables.
variables
{
message 0x555 msg1 = {dlc=1};
}
on key ‘b’
{
msg1.byte(0)=0xAA;
output(msg1);
}
When information requires transferring on a repetitive basis, the periodic message is used.
To send the periodic message requires the use of a timer and this timer must be defined by name
in the global variables area. To get this timer running, we have chosen to initialize the timer in the
“on start” event procedure which is executed upon clicking on the tool start button. We need to
use one of the intrinsic CAPL functions called setTimer to initialize the time value to 100
milliseconds.
When this timer expires (or times out), the corresponding “on timer” event procedure will be
executed. Within this “on timer” event procedure the timer will be reset again to 100 milliseconds.
Additionally, we increment the first message data byte before sending the CAN message using
the CAPL output function.
This repetitive process will continue until one clicks on the tool’s stop button.
variables
{
message 0x555 msg1 = {dlc=1};
mstimer timer1; // define timer1
}
on start
{
setTimer(timer1,100); // initialize timer to
100 msec
}
on timer timer1
{
setTimer(timer1,100); // reset timer
With respect to the CAPL program development, for this periodic message example, CAPL code
must be entered into three different locations and a total of 6 lines of code are used.
To send a conditionally periodic message also requires the use of a timer, but this timer does not
need to run continuously. We have chosen to activate or deactivate the timer based upon the
pressing of the ‘a’ key sequence. The first press of the “a” key will start the periodic message and
the second press of the ‘a’ key will stop the periodic message. Each subsequent press of the ‘a’
key will toggle back and forth between these two states.
Notice in the global variables, we have defined a different message and timer name than was
used for our periodic message example. This allows you the opportunity to experiment with both
message transfer methods inside the same CAPL program if desired.
To properly start the process in the inactive state, we have defined an integer variable called
conditionA in the global variables area and have initialize its value to 0 which represents the off
condition.
Once the user presses the ‘a’ key, the corresponding on key procedure will execute. This
procedure will toggle the condition variable and check to see if the condition is active or true. If
the condition is active, then the timer will be started.
When this timer expires, the corresponding “on timer” event procedure will be executed. The
timer is reset to continue running and after modifying the data the CAN message is transmitted.
Notice that when the condition has been toggled back to the off condition, it will be the next timer
event that actually stops the timer from running.
This conditionally repetitive process will continue until the tool is stopped.
With respect to the CAPL program development, source code must be entered into three different
locations and a total of 10 lines of CAPL code are used.
variables
{
message 0x400 msgA = {dlc=1};
mstimer timerA;
int conditionA = 0; // initialize conditionA
= off
}
on key ‘a’
{
conditionA =! conditionA; // toggle conditionA
if(conditionA == 1) // if condition is active
{
setTimer(timerA,200); // then start timer
}
}
on timer timerA
{
if(conditionA == 1) // if condition is still
true
{
setTimer(timerA,200); // then continue timer
}
msgA.byte(0)=msgA.byte(0)-1; // change the data
output(msgA); // output message
}
Note for the CANoe Users: If you are using CAPL with CANoe, you need to understand the
concept of environmental variables. Environmental variables are used in CANoe to represent
external values on the network, such as the position of a switch. The environmental variables are
defined in an associated database with CANdb, and can be read and changed by your CAPL
programs.
2. Event Procedures
Event procedures are blocks of code that are executed when an event occurs. CAPL allows
you to define event procedures for several different kinds of events. Most of your program
code will be in event procedures, since most actions are performed after an event, such as a
message being received on the CAN bus. Event procedures cannot return a value.
3. User-Defined Functions
Your programs can contain procedures that can be used to complement CAPL’s built-in
functions. These procedures can contain any legal CAPL code and are globally accessible.
Putting frequently-used code in a procedure makes programs more efficient. User-defined
functions can return a value of any simple type.
In the chapter on using the CAPL Browser, you will see how the editor itself is designed to help
you write each of these three parts of your program.
Notation Meaning
. . . When used in source code, an ellipse means that any code is
valid in this place. It is used to indicate that code unrelated to
the specific example would often exist, but has been removed
for readability purposes.
Source code appears in a fixed-width courier font.
the write() function Names of functions not in the context of source code are
followed by parentheses to indicate that they are functions.
Note that this does not mean that the function takes no
parameters.
Logical Operators
&&, || Logical AND, logical OR
?: Conditional operator
! Logical negation
Bitwise Operators
~ Bitwise negation
Program organization and each of CAPL’s built-in functions is explored in detail later in
this manual.
print(5.7);
“Floating point 5.700000”
print(2.5, “angstroms”, 22);
“2 angstroms”
The last case is the most interesting. Since there are no overloaded functions with three
parameters, the function with two parameters is chosen. Since the first parameter to that function
is expected to be an integer, the floating point value 2.5 is first cast to an integer (2) before being
passed to the function. The third parameter (22) is discarded.
The “this” pointer can be used similarly for environmental variables. The event shown below is
triggered when the value of the environmental variable Switch changes. In order to read the new
value, you can use the “this” keyword with the getValue() function.
on envVar Switch { // Triggered when Switch changes
int val;
val = getValue(this); // Read value of Switch into val
}
Warning: Changes make to the “this” pointer remain local. The value of the “this” pointer may be
modified and passed as a function parameter, but the value will be lose upon the end of the “on
message” or “on envVar” procedures.
The first time myFunc is called, it will print “value = 10” as expected. However, the second and all
subsequent times the function is called, it will print “value = 35”. Due to this semantic, the
preferred way to initialize non-static variables is to use a separate assignment after the variables
has been declared. In this example, the variables are reset to their initial values at the beginning
of every iteration of the function:
void myFunc() {
// Variable declarations
byte value;
int x, y;
// Variable initializations
value = 10;
x = 0;
y = 5;
answer = 0;
on start
{
sum(mat1); // prints 10
sum(mat2); // prints 45
}
In the above example, notice how elCount() is used in sum() twice, once in the inner “for” loop
and once in the outer “for” loop. In the outer loop, elCount(matrix) returns the size of the first
array dimension. In the inner loop, elCount(matrix[i]) returns the size of the second array
dimension. In combination, these loops are used to cycle through every index of the two-
dimensional arrays.
The sample code below uses the “Off” symbolic value name instead of the actual decimal value
of 3. Clearly, this provides many advantages, including being able to change the numeric value
corresponding to the “Off” state without changing any CAPL code.
on message LightStatus {
if (this.State == LightStatus.State::Off)
write (“The light is off.”);
else write (“The light is not off.”);
-
From CAPL’s perspective, a user-defined database attribute is a constant value that you can read
in your CAPL programs. The values of the attributes can be changed in the database after each
successive measurement, allowing you to modify the behavior of your CAPL program without
altering the source code.
To access an attribute’s value in CAPL, append a period (.) and the name of the attribute to the
name of the database object. The object types are listed above, and examples of accessing
attributes for each object type are below.
For this example, we will use CANdb to create a database named AUTO.DBC. Then we will
associate the database with a new CAPL program. Inside AUTO.DBC, we will create an
environmental variable called leftWindowButton with an attribute called style (type enum, with
values Button and Toggle). An database attribute called revision will be created as a string. We
will create a node called displayConsole and a message called windowControl. The message will
contain a signal called windowHeight. For clarity, here is how each attribute corresponds to each
database object:
Note that in CAPL, enum data types are treated like strings. So when we read from the style
attribute, we are actually reading the string “Button” or “Toggle”. We use the strncpy() function for
this, just as we do for reading the revision string.
One important difference from C is that in CAPL, local variables are always created statically.
This means that an initialization is only executed at the program start, and when variables enter
the procedure they assume the value they had at the end of the previous execution of the
procedure.
Examples of variable declarations:
int j, k = 2; /* j = 0 implicitly */
double x = 33.7;
char p;
Note: You can initialize multi-dimensional arrays using the syntax shown. You can also initialize
character arrays with string constants.
Note that appending an “x” to the message ID tells CAPL that the identifier you specified is an
extended (29 bit) CAN ID. The default is the standard (11 bit) CAN ID.
You also need to specify the amount of data a message is going to contain. One way to do this
is to use the DLC (data length code) message selector as part of the message declaration. Other
message selectors will be covered later in this chapter. For example:
// Declare message ID FF (hex) with 4 data bytes
message 0xFF rearAxle = { DLC = 4 };
The CAPL Browser makes signal selection easy by allowing you to insert a signal name from an
associated database using a pull-down menu system. Right-click on the location where you want
to insert the signal name, choose “CANdb Signal”, choose the message containing the signal,
and then choose the signal name.
So for our example, entering a Factor of 2.0 and an Offset of 0 would allow us the desired range
of numbers. To access the physical value (and have CAPL automatically convert the number to
the appropriate raw value), simply add “.phys” to the signal name. Using the EngData example
from the above section, using the physical value would look like this:
message EngData EDMsg; // Declare EDMsg as type EngData
EDMsg.EngSpeed = 50000; // Set raw value
EDMsg.EndSpeed.phys = 50000; // Set physical value
Note that if a conversion formula is defined for EngSpeed, the two assignment statements do not
have the same effect. You should almost always use the .phys attribute whenever you have a
formula defined; not doing so can cause bugs that are difficult to track down.
Then the conversion formula is used to calculate a raw value of 2000.5. Since only discrete (or
whole number) values are legal, 2000 is saved in EDMsg.EngSpeed. The next time we read the
value of EDMsg.EngSpeed.phys, the conversion formula is used to produce the value 4000.
Both the DIR and TYPE selectors provide predefined constants that you can use to make your
CAPL programs more readable. The TYPE selector is provided as an efficient way to evaluate
other selectors as one unit:
Eight Byte Seventh Byte Sixth Byte Fifth Byte Fourth Byte Third Byte Second Byte First Byte
When using the getValue() function with a string, notice that you must supply a buffer as the
second argument of the function call. This is different from using getValue() to read a number.
For example:
char[100] lightColor; // A 100-character buffer
// will suffice for the string
int lightState; // Light state is an integer
The following is a complete list of all of the available events. Note that the last event, on envVar,
is only available if you are using CANoe. Event statements with an italicized parameter indicate
event statements that require a parameter. Since its use changes, the last column indicates how
you can use the “this” pointer inside each event procedure. For more detailed explanations, see
the section corresponding to each event type.
CAN controller goes into ErrorActive state on errorActive contains error counts
CAN controller goes into ErrorPassive state on errorPassive contains error counts
CAN controller goes into Warning Limit state on warningLimit contains error counts
CAN controller goes into Bus Off state on busOff contains error counts
Environment variable change (CANoe only) on envVar env. variable the env. variable
Note: If more than one message parameter applies, then only the most specific event procedure
is executed. These two precedence rules apply:
• Specification of a chip number has precedence over the absence of a chip number.
• Specification of a message ID number has precedence over a wildcard.
It is important to remember that if you want to perform an action on all messages received, an “on
message *” event procedure will not be executed if another “on message” event procedure is
triggered.
on key 'a' Event occurs when the (lower case) "a" key is pressed
on key 'A' Event occurs when the (capital) "A" key is pressed
The last event syntax, “on key *”, can be useful if you want to write all of your keystroke-handling
routines in one event procedure, or if you want to have several different keystrokes execute the
same instructions. The “this” keyword is used to determine the actual key that was pressed. For
example:
on key * {
switch(this) { // “this” holds the value of the key
Note: If an “on key*” event procedure is declared as well as an “on key ‘a’” event procedure, only
the “on key ‘a’” event procedure is executed when the ‘a’ key is pressed. Only the most specific
event procedure is executed when more than one event statement matches the event.
Note for the CANoe Users: It may be necessary to execute the same actions with environmental
variables at the beginning of the measurement as when the values of environmental variables
change during the measurement. These actions may include initializing variables, setting timers
related to environmental variables, and sending out messages onto the bus containing values of
environmental variables. To aid you in executing all of your environmental variable event
procedures, CAPL provides the CallAllOnEnvVar() function. This calls every environmental
variable event procedure that you have defined. CallAllOnEnvVar() is normally called from the
start event procedure.
When you press the Stop button in CANalyzer or CANoe, the stopMeasurement event procedure
is executed (if one exists). You can use this procedure to print statistics in the Write window,
output messages onto the bus, or write to a log file. After this event has finished executing, the
measurement is stopped.
The Warning Limit interrupt is not a state, but rather an interrupt that originates in the CAN
controller. The interrupt occurs when either the receive or transmit error counts exceed 96.
(Note: For some CAN controllers, the error count can be set, but defaults to 96. See the
documentation for your CAN controller for more information.)
Although interrupts and state changes are different, CAPL treats them both as events; therefore,
there is no difference in implementing the errorActive, errorPassive, warningLimit, or busOff
events. The event procedures can be used to print a warning message to the Write window or to
automatically stop the measurement. Inside these event routines, the “this” keyword allows you
read-only access to the CAN controller’s error counters.
For example, if you want to output a warning when the Error Warning Level is reached and stop
the measurement if the controller goes into the Bus Off state, this is the implementation:
on warningLimit
{
write (“CAN controller is in the Warning Limit state.”);
write (“ Transmit errors = %d”, this.errorCountTX);
write (“ Receive errors = %d”, this.errorCountRX);
}
on busOff
{
write (“CAN controller is in the Bus Off state.”);
write (“Stopping measurement.”);
stop();
}
2.9.5 The “on timer” event and the setTimer() and cancelTimer() functions
CAPL allows you to create timers for seconds (Timer) or milliseconds (msTimer). After these
timers have been set and expire, the corresponding “on timer” event procedure is executed. This
facility can be used to create a cyclic event if you reset the timer at the end of the timer event
procedure. Timers can also be used to respond to an event after a delay.
The setTimer() function takes two parameters, the name of the timer and the length of time to set
the timer. The length of time parameter has different units depending on what kind of timer you
are using. For a Timer, the units are seconds; for an msTimer, the units are milliseconds. The
maximum values are 1799 seconds and 65,535 milliseconds, respectively. The cancelTimer()
function can be called on a timer before it has expired to prevent the timer event from triggering.
Calling the cancelTimer() function has no effect if the timer is not set or has already expired.
An example of a cyclic timer with a 20 millisecond period:
variables {
msTimer t;
. . .
}
on start {
setTimer(t, 20);
. . .
}
on timer t {
. . . // Perform some action here
setTimer(t, 20);
}
In the Measurement Setup window in CANalyzer, the placement of your P-Blocks has important ramifications on
your CAPL programs. P-Blocks are inherently not transparent to bus events. This means that a message or error
frame in the evaluation branch (of CANalyzer or CANoe) will not pass through a P-Block unless the P-Block is
specifically told to pass it on. To make a P-Block allow messages and error frames to pass though, you would write
the following CAPL code:
on message * {
. . . // Insert your code here if desired
output(this);
};
on errorFrame {
. . . // Insert your code here if desired
output(errorFrame);
};
Recall that if another message event procedure is executed instead of the “on message *” event
procedure, then the on “message *” event will not be executed. If you want to pass on those
messages, include the same “output(this)” line in the event procedures corresponding to those
messages.
However, you should not include this code in P-Blocks in CANalyzer’s transmission branch or in
CAPL programs in CANoe’s Simulation Setup window. This causes an infinite loop to occur,
which is rarely the desired effect. For each message received, the reaction is to immediately re-
send the same message, causing the message to be received again. This repeats until the
simulation is stopped.
It is also important to be aware that some built-in CAPL functions are not allowed in some areas. Mostly, this means
that file-related functions are not allowed in CANoe’s Simulation Setup window or CANalyzer’s transmission branch.
See the chapter on CAPL functions for more information.
It is beyond the scope of this manual to cover how to use logging in CANalyzer and CANoe, but
there are some concepts that you must understand to use CAPL to control logging. Since logging
an entire simulation can produce large log files containing mostly extraneous data, CAPL allows
you to selectively log portions of a simulation. When the conditions to begin logging are met, you
call the trigger() function in your CAPL code.
The pretrigger time is the period of time to record bus activity preceding the call to the trigger()
function. The posttrigger time is the period of time to record bus activity following the call to the
trigger() function. For example, assume that the start of a given measurement occurs at 0.0
seconds. We will set the pretrigger time to 1 second and the posttrigger time to 2 seconds. If a
call to trigger() occurs at 7.2 seconds into the simulation, then the bus activity between 6.2
seconds and 9.2 seconds is recorded in the log file.
To implement this example in CAPL code, the following functions are used: trigger(),
setLogFileName(), setPreTrigger(), and setPostTrigger(). Note that these functions can only be
used in P-Blocks in the analysis branch of CANalyzer’s simulation setup window or in CANoe’s
simulation setup window. Attempting to compile programs utilizing these functions in the CAPL
Browser will lead to an error message. Therefore, you need to compile these programs with
CANalyzer or CANoe’s compile command.
The CAPL Browser is the program that comes with CANalyzer and CANoe which is designed to
help you develop CAPL code as quickly and easily as possible. It is versatile in that you can
choose to use all of its powerful features, or slowly progress up the curve, using only its basic
features at first.
Within the browser program itself, you can develop new programs, import and export source files, and compile your
code. The integrated compiler makes it easy to debug your CAPL programs.
Note for the right mouse button: The right mouse button provides context-sensitive
functionality in most CAPL Browser windows. Learning how and when to use the pull-down
menus that the right mouse button accesses will allow you to use the program effectively.
When in doubt, try clicking the right mouse button in a CAPL Browser window.
New (Control-N) Create a new CAPL source code file. CAPL Browser opens a new, blank Browser
window. When you save or close this window, you will be asked for a file name.
Open (Control-O) Display a file selection dialog box in which you can select a CAPL
source file to open. If you enter the name of a file that does not exist, a new file is created
with this name. If CAPL Browser cannot display the file that you want to open, it will ask you
if you want to open the file in a text editor.
Close Close the active Browser window. If you have made changes to the currently open
file, the CAPL Browser will ask if you would like to save the changes before you close the file.
Save (Control-S) Save the active window. If you have not assigned a file name yet, you
will be prompted to name the file before it is saved.
Save as... Assign a file name and save the active window. You can use this command to
create another copy of the current source code window. If you specify a file name that is
already in use, you are asked if you would like to overwrite the original file.
Import Read in a program which was not developed in the CAPL Browser. During the
process, the CAPL Browser attempts to determine the structure of the program. If this fails,
then the CAPL Browser displays the file in one text window instead of the normal four CAPL
Browser windows.
Export Save a CAPL program in ASCII format. The output file does not contain any
structure information that is used by the CAPL Browser, and therefore is human readable. If
you wish to open this file in the CAPL Browser at a later time, you must use the Import
command discussed above.
Associate database Associate a database created with CANdb with this CAPL
program. This allows you to use symbolic names for message and pg identifiers, signal
names, environmental variables, and attributes that are defined in the database. Selecting
this command opens a new window that allows you to add, delete, and modify database
associations. Using this window you can associate several databases with your program.
Preview Show a preview of what will be printed on screen. This opens a new preview
window with buttons that allow you to scroll through the pages of your source code and
toggle between a one-page or two-page display. The red “x” button allows you to close the
print preview window.
Print Print your CAPL source code. This opens a window that allows you to select a
printer and which pages you would like to print.
Print Setup Modify printer settings. This opens a window that allows you to change
printer-specific options like paper size and orientation. This should be used before you print.
Exit (ALT-F4) Exit the CAPL Browser. If you have source files open with unsaved
changes, you will be prompted to save each file before the CAPL Browser exits.
Undo (Control-Z) Although it is not listed in the Edit menu, the Undo command is
available in the CAPL Browser. To undo the last editing change that you made, press
Control-Z.
Cut (Control-X) Delete the selected text and save it in the clipboard. To put the text
back into your source file, use the Paste command.
Copy (Control-C) Copy the selected text to the clipboard without changing your source
code. To insert this text elsewhere in your source code, use the Paste command.
Paste (Control-V) Insert the text on the clipboard at the cursor location.
Delete (Delete key) Delete the currently selected text without copying it to the clipboard.
CAPL Function Insert the name of a CAPL function at the cursor location. A window is
opened that allows you to choose which function to insert. This command is also available by
using the right mouse button in the appropriate editing window.
CANdb Message Insert a symbolic message name from an associated database at the
cursor position. This command opens a new window that allows you to select the name of the
message that you wish to insert. This command is not available if no databases are
associated with the current source file.
CANdb Signal Insert a symbolic name for a signal from an associated database at the
cursor position. This command opens a new window that first requires you to select the
message containing the signal, and then the name of the signal. This command is not
available if no databases are associated with the current source file.
Find Search through the text in the current editing window for the text that you specify.
(This command does not search through your entire program.) Selecting this command
opens a window that allows you to set search options and enter the text that you want to find.
After pressing the “Find Next” button, the first match is highlighted on the screen. You can
continue to press the “Find Next” button to find each successive match.
Replace Replace specified text with new text in the current editing window. Selecting this
command opens a window that allows you to specify the text to replace and the new text as
well as other options. The “Find Next” button highlights the next match, and the “Replace”
button makes the replacement and highlights the next match. You can use these buttons to
selectively make replacements, since the “Find Next” button does not alter your source code.
Next Repeat the previously executed search action, whether it was done with the Find
command or the Replace command. This command only affects the current editing window.
New Insert a new procedure into the Event Procedures list for the current event type.
This may not be available if you have already inserted the maximum number of procedures in
one category. For example, the ErrorFrame category can only have one event procedure
defined. If a category has predefined event names, then a submenu is opened next to the
New command to choose a predefined name.
Delete Delete the selected procedure from the Event Procedures window. All of the code
associated with this procedure is also deleted.
Compile (F9) Compile the selected CAPL program. See the section on compiling for
more information.
Compile All Compile all open CAPL programs. See the section on compiling for more
information.
Find runtime error Find a runtime error in your CAPL code. This command opens a
window that allows you to enter an error code reported by CANalyzer or CANoe and find the
place in your CAPL program where the error occurred.
Editor Open a window to allow you to change editor settings such as font, tab stops, and
tool bar display.
Compiler Allow you to toggle between the real-time and analysis branches for the placement of your
CAPL node. Some CAPL functions are not available in the real-time branch.
Tile Displays all open windows, giving each an equal amount of the screen.
Arrange Icons Arrange minimized window icons along the bottom of the screen.
Contents Open the table of contents for the CAPL Browser help.
About Display version and copyright information for the CAPL Browser program.
The toolbar allows quick access to commands that are also available in the pull-down menus.
For more information on the commands, see the documentation in the respective pull-down menu
section. At times, certain buttons will be “grayed out” when they are not available for use. Often,
clicking the mouse in the correct window or selecting text will allow you to use the buttons.
The Global Variables window, in the upper right corner of the CAPL Browser, allows you to enter
global variables for your CAPL program. The advantage of having them in a separate window is
that they are always visible when you are editing your event procedures, and you can easily edit,
add, or remove a variable without losing your place in the code you are editing.
In this area, you can declare variables of any type inside the variables { . . . } construct.
You can use the right mouse button to activate a pull-down menu with editing options and the
ability to insert CAPL functions.
The Event Procedures window, in the lower left corner of the CAPL Browser, lists the event
procedures defined for the event category currently selected in the Event Types window. Some
event categories allow only a small number of CAPL-defined functions (like System), while others
(like Message) allow you to define as many event procedures as you want (in this case,
corresponding to messages IDs received).
In this window, the right mouse button activates a menu that allows you to create or delete an
event procedure. For event categories that only allow CAPL-defined procedures, the New menu
option extends to a submenu which allows you to pick one of the CAPL-defined procedures.
The Procedure Editing window, in the lower right corner of the CAPL Browser, is the place where
you enter the code for your event procedures. After you create a new event procedure in the
Event Procedures window, a skeletal procedure is set up for you. In most cases, you need to fill
in the details of the procedure declaration. For example, if you choose to create a new “on
errorFrame” event procedure, the Procedure Editing window will have this code in it:
on errorFrame
{
}
This event procedure declaration is complete as it is and does not need to be modified. You can
begin writing you code between the braces. On the other hand, if you create a new message
event procedure, you are presented with this:
on message <newMessage>
{
}
This is the generic skeletal code for an “on message” event procedure, and you need to fill in the
identifier, replacing the text . After the identifier has been specified, then you
can begin writing the event procedure code between the braces.
The line that begins with “Locate with CAPL browser...” reports the error number following
the “->” (in this example, this line has been wrapped onto the next line). Using the Compile
menu, select the “Find runtime error” command and input the error number (in this example, the
error number is 1). The CAPL Browser will then show you where this run-time error occurred.
/*@@var: */
variables {
msTimer T1;
}
/*@@end */
/*@@timer:T1: */
on timer T1 {
message 100 M100 = {dlc=4, word(0) = 0xaaaa, word(2) = 0x5555};
setTimer(T1,50);
M100.byte(0) = M100.byte(0) + 1;
output(M100);
}
/*@@end */
/*@@startStart: */
on start {
setTimer(T1,50);
}
/*@@end */
There’s no special requirement for the spacing between the difference CAPL-specific sections
and any number of blank lines may be used in between procedures. Programmers that develop
CAPL source programs outside of the normal CAPL browser may further use comment fields to
enhance readability and potentially improve the documentation quality of CAPL programs.
4 CAPL Functions
[CAPL-INI]
Warning: Do not open or modify the WIN.INI or SYSTEM.INI files using CAPL's file functions.
Warning: Due to the way that INI files are parsed, comments must start at the beginning of
a new line. Otherwise, unpredictable results will occur.
[CAPL]
SeqFilePath=”C:\usr\max\capldata”
; working folder for files that are to be read from
; CAPL with seqFileLoad
When seqFileLoad() is called to open a file, the path specified inside the quotation marks is
searched for the file. If the file cannot be found in that directory, the system (e. g. EXEC or
EXEC32) directory is searched for the file. If CANalyzer or CANoe is running while you edit
CAN.INI, you must restart the program for your change to take effect.
Since the CAPL Browser cannot tell where the P-Block is placed in the setup window of
CANalyzer or CANoe, sometimes it will not compile CAPL programs containing some functions
(for example: setLogFilleName()). In this case, compile the CAPL program using the compile
option in CANalyzer or CANoe. This provides the compiler with the location of the P-Block,
allowing normally restricted function calls.
Math Functions
abs Calculate an absolute value
cos Calculate a cosine
exp Calculate an exponent
random Calculate a random value
sin Calculate a sine
sqrt Calculate a square root
Timer Functions
cancelTimer Stop an active timer
setTimer Set a timer
Logging Functions
setLogFileName Set the file name of the log file
setPostTrigger Set the posttrigger time for logging
setPreTrigger Set the pretrigger time for logging
trigger Activate logging triggering
writeToLog Write a formatted string to the log file
Time Functions
timeDiff Calculate time difference between two messages
timeNow Get current system time
getLocalTime Get array time information
getLocalTimeString Get human-readable time string
Miscellaneous Functions
elCount Count the number of elements in an array
J1939-Specific Functions
getThisMessage Read data from a parameter group
CANalyzer CANalyzer
CANoe CANoe
CANalyzer (Windows) (Windows)
Function Simulation Measurement
(DOS) Transmission Analysis
Setup Window Setup Window
Branch Branch
abs b b b b b
atol b b b b b
beep b b b b b
callAllOnEnvVar b b
cancelTimer b b b b b
canOffline b
canOnline b
cos b b b b b
elCount b b b b b
exp b b b b b
fileName b b b b b
fileReadArray b * * b b
fileReadFloat b * * b b
fileReadInt b * * b b
fileReadString b * * b b
fileWriteFloat b * * b b
getCardType b b b b b
getChipType b b b b b
(Continued on next page)
b= can be used
* = can be used if CAPL.INI or CAN.INI is configured correctly.
CANalyzer CANalyzer
CANoe CANoe
CANalyzer (Windows) (Windows)
Function Simulation Measurement
(DOS) Transmission Analysis
Setup Window Setup Window
Branch Branch
getLocalTime b b
getLocalTimeString b b
getValue b
getValueSize b b
input b b b b b
isStdld b b b b b
keypressed b b b b b
Itoa b b b b b
mkExtld b b b b b
output b b b b b
putValue b b
random b b b b b
resetCan b b b
runError b b b b b
seqFileClose * *
seqFileGetBlock * *
seqFileGetLine * *
seqFileGetLineSZ b b
seqFileLoad b b
seqFileRewind b b
(Continued on next page)
b= can be used
* = can be used if CAPL.INI or CAN.INI is configured correctly.
CANalyzer CANalyzer
CANoe CANoe
CANalyzer (Windows) (Windows)
Function Simulation Measurement
(DOS) Transmission Analysis
Setup Window Setup Window
Branch Branch
setBtr b b b
setLogFileName b b
setMsgTime b b b b b
setOcr b b b b b
setPreTrigger b b
setPostTrigger b b
setTimer b b b b b
sin b b b b b
snPrintf b b
sqrt b b b b b
stop b b b b b
strlen b b b b b
strncat b b b b b
strncmp b b b b b
strncpy b b b b b
swapDWord b b b b b
swaplnt b b b b b
swapLong b b b b b
swapWord b b b b b
(Continued on next page)
b= can be used
* = can be used if CAPL.INI or CAN.INI is configured correctly.
CANalyzer CANalyzer
CANoe CANoe
CANalyzer (Windows) (Windows)
Function Simulation Measurement
(DOS) Transmission Analysis
Setup Window Setup Window
Branch Branch
sysExit b b
sysMinimize b b
timeDiff b b b b b
timeNow b b b b b
trigger b b b b b
valOfld b b b b b
write b b b b b
writeToLog b b b
b= can be used
* = can be used if CAPL.INI or CAN.INI is configured correctly.
abs abs
Function This function returns the absolute value of a signed number. Note that this
function is not necessary for the unsigned byte type.
Returns Integer, long integer, or double. Return type matches the parameter type.
Example
int one = -1;
long two = -2;
double three = -3.0;
atol atol
Function This function converts the string s to a long number. The number base is
decimal. If the string starts with “0x”, base 16 is used. Leading blanks are
discarded.
Example
...
long z1;
long z2;
z1 = atol(“200”);
z2 = atol(“0xFF”);
...
beep beep
In the Windows version, the parameters freq defines the tone output.
Different sounds are defined in the section [SOUND] in the file WIN.INI:
Note If you do not have a sound card installed in your computer, Windows will generate
a normal system beep. In this case, the freq parameter has no effect.
Returns none
Example
void sound() {
// with soundcard: 400 Hz beep
// without soundcard: standard system beep
beep (400,0);
}
callAllOnEnvVar callAllOnEnvVar
Syntax callAllOnEnvVar();
Function Calls all event procedures for environment variables (onEnvVar). This can
be necessary at the start of measurement to initialize environment variables,
to start timers activated in response to changes of environment variables, or
to send messages on the bus with the start values of the environment
variables.
Parameters none
Returns none
Example on start
{
callAllOnEnvVar();
}
cancelTimer cancelTimer
Function Stops an active timer that has been set with setTimer(). This prevents the
timer event procedure from being executed. If called on a timer that is not
set, this function has no effect.
Returns none
Example
variables {
msTimer msgTimer;
message dataMsg dMsg;
}
on timer msgTimer {
send(dMsg);
setTimer(msgTimer, 200);
}
on key F1 {
cancelTimer(msgTimer); // cancel timer
write(“msgTimer canceled”);
}
on key F2 {
setTimer(msgTimer, 200); // set timer to 200 ms
write(“msgTimer started”);
}
canOffline canOffline
Syntax canOffline();
Function Cuts the connection between the node and the bus. Messages sent from the
node are not passed through to the bus. The function canOnline() will
restore the connection to the bus.
Parameters none
Returns none
Example ...
canOffline();
...
Compatiblity This function can only be used in nodes in CANoe’s Simulation Setup
window.
canOnline canOnline
Syntax canOnline();
Function Restores the connection of the node to the bus. After a call to the function
canOffline() the node can be connected to the bus with the function
canOnline(). Messages sent from the node are passed through to the bus.
Parameters none
Returns none
Example ...
canOnline();
...
Compatibility This function can only be used in nodes in CANoe’s Simulation Setup
window.
cos cos
Returns Cosine of x.
Example
double x;
x = cos(PI); // result -1, PI is a built-in
constant
double tangent(double x) {
return sin(x) / cos(x);
}
elCount elCount
Example
// One-dimensional array
void bsp(int ar[]) {
int i;
for(i=0; i < elCount(ar); i ++)
...
}
// Two-dimensional array
void bsp2(byte ar[][]) {
int i, j;
for(j=0; j < elCount(ar); j ++ )
for(i=0; i<= elCount(ar[j]); i ++ )
...
}
Note: For the two-dimensonal array, elCount(ar) is used to get the number of elements in the
first dimension and elCount(ar[j]) is used to get the number of elements in the second
dimension.
exp exp
Function Calculate the value of the exponential function with a given degree
Example
double x;
x = exp(1.0); // Result: 2.7182...
fileName fileName
Syntax fileName();
Function Output the name of the CAPL program in the Write window. Helpful for
debugging purposes.
Parameters none
Returns none
Example
...
fileName();
...
fileReadArray fileReadArray
Function Searches for the variable entry in the section section of the file file. Its
contents are interpreted as a list of byte values. The number format is
decimal or with the prefix 0x it is hexadecimal. Numbers are separated by
spaces, tabs, a comma, semi-colon or slash. The buffer is filled up to a
quantity of bufferlen bytes.
Note This function is equivalent to the fileReadString() function. Since there is not
a corresponding fileWriteArray() function, you can use fileWriteString() to
write formatted strings to a data file that can later be read with
fileReadArray() or fileReadString().
Example
Data in TEST.INI:
[DATA]
FIELD=1,2,3,0x20,100
CAPL Code:
...
int len;
char buf[20];
len = fileReadArray(“DATA”, “FIELD”, buf, elCount(buf), “TEST.INI”);
...
Result: len = 5. The array buf is filled with the values 1,2,3,32,100.
Compatibility This function has restricted compatibility. Please see the function
compatibility chart for more details.
fileReadFloat fileReadFloat
Function Searches for the variable entry in the section section of the file filename. If
its value is a number, this number is returned as the functional result. If the
file or entry is not found, or if entry does not contain a valid number, the
default value def is returned as the functional result.
Returns The floating point number read if it is found in the data file, otherwise the
value of the def parameter.
Example
Data in TEST.INI:
[DATA]
VOLUME=3.3000
CAPL Code:
...
float vol;
vol = fileReadFloat(“DATA”, “VOLUME”,0,“TEST.INI”);
...
Result: vol contains the value read or 0 if the data item was not found in the
datas file.
Compatibility This function has restricted compatibility. Please see the function
compatibility chart for more details.
fileReadInt fileReadInt
Function Searches for the variable entry in the section section of the file filename. If
its value is a number, this number is returned as the functional result. If the
file or entry is not found, or if entry does not contain a valid number, the
default value def is returned as the functional result.
Returns The integer read if it is found in the data file, otherwise the value of the def
parameter.
Example
Data in TEST.INI:
[DATA]
ADDR=200
CAPL Code:
...
myAddress=fileReadInt(“DATA”,“ADDR”,0, “TEST.INI”);
...
Result: The value 2 is assigned to the variable myAddress. If the entry ADDR
does not exist in the file TEST.INI the default value 0 is assigned to
myAddress.
Compatibility This function has restricted compatibility. Please see the function
compatibility chart for more details.
fileReadString fileReadString
Function Searches for the variable entry in the section section of the file filename. Its
content (value) is written to the buffer buffer. Its length must be passed
correctly to bufferlen. If the file or entry is not found, the default value def is
copied to buffer.
Example
Data in TEST.INI:
[DATA]
NAME=Marty
CAPL Code:
...
int len;
char buf[20];
fileReadString(“DATA”, “NAME”, buf, elCount(buf), “TEST.INI”);
...
Compatibility This function has restricted compatibility. Please see the function
compatibility chart for more details.
fileWriteFloat fileWriteFloat
Function Opens the file filename, finds the section section and writes the variable
entry with the value value. If entry already exists, the old value is
overwritten. The functional result is 1 for success, or 0 for an error.
Example
...
if(!fileWriteFloat(“DeviceData”, “DeviceAddr”, 2.2, “TEST.INI”))
write(“Error writing DeviceAddr to TEST.INI”);
...
fileWriteInt fileWriteInt
Function Opens the file filename, finds the section section and writes the variable
entry with the value value. If entry already exists, the old value is
overwritten. The functional result is 1 for success, or 0 for an error.
Example
...
if(!fileWriteInt(“DeviceData”, “DeviceAddr”, 2, “TEST.INI”))
write(“Error writing DeviceAddr to TEST.INI”);
...
Compatibility This function has restricted compatibility. Please see the function
compatibility chart for more details.
fileWriteString fileWriteString
Function Opens the file filename, finds the section section and writes the variable
entry with the value value. If entry already exists, the old value is
overwritten. The functional result is the number of characters written, or 0 for
an error.
Example
if(!fileWriteString(“Device”, “DeviceName”, “LPT1”, “test.ini”))
write(“File error”);
...
Compatibility This function has restricted compatibility. Please see the function
compatibility chart for more details.
getCardType getCardType
Function Determines the type of CAN platform being used. Is needed e.g. to program
the BTR (Bit Timing Register) and OCR (Output Control Register) values.
Parameters None
Example
...
switch(getCardType()) {
case 6: setOcr(0,0x02); // CANAC2
break;
case ...
default:
write(“Unknown driver %d”, getCardType());
break;
}
...
getChipType getChipType
Parameter channel:
0 = both controllers
1 = Channel 1
2 = Channel 2
5 NEC 72005
200 Philips PCA82C200
462 MHS29C462 VAN Controller
526 Intel 82526
527 Intel 82527
Other types may occur. Demo versions return the result 0 or simulate one of
the existing types. If an attempt is made to access a nonexistent channel
(e.g. Channel 2 for CPC/PP) or if the driver used does not support this
function, the functional result is 0.
Example
...
switch(getChipType( )) {
case 200: setOcr(0,0x02); // Philips PCA82C200
break;
case ...
default:
write(“Unknown CAN chip type: %d”,
getChipType());
break;
}
...
getLocalTime getLocalTime
Function Fills an array of type long with details of the date and time.
The entries of the array will be filled with the following information:
timeArray[1] Minutes 0 – 59
timeArray[2] Hours 0 – 23
Returns Nothing
getLocalTime(timeArray);
Compatiblity This function can only be used in P-Blocks located in the analysis branch of
CANalyzer’s Measurement Setup window or in P-Blocks in CANoe’s Mea
surement Setup window.
getLocalTimeString getLocalTimeString
Function Copies a string representation of the current date and time into the supplied
character buffer. The format of the string is
ddd mmm dd hh:mm:ss yyyy (e.g., “Fri Aug 21 15:22:24 1998").
The string is null-terminated.
Parameters The buffer in which the string will be written. This buffer must be at least
26 characters long. Unpredictable results will occur if the buffer is not
at least 26 characters long.
Returns none
Example ...
char timeBuffer[64];
getLocalTimeString(timeBuffer);
Compatiblity This function can only be used in P-Blocks located in the analysis branch of
CANalyzer’s Measurement Setup window or in P-Blocks in CANoe’s Mea
surement Setup window.
getThisMessage getThisMessage
Function Transfers the this parameter group to the indicated parameter group pg. The
number of bytes of the transmitted parameter group data is given by length.
This function must be used exclusively within the program block, and is only
used with J1939 buses.
Return None
Example
pg TC1 pg_tc1; // Definition of a parameter group
getValue getValue
Parameters Environment Variable name for Forms 1 and 2. Environment variable name
and return buffer for Form 3.
Returns Active value of the environment variable for Forms 1 and 2. No return value
for Form 3.
Example
int val;
float fval;
char buff[25];
...
Compatibility This function has restricted compatibility. Please see the function
compatibility chart for more details.
getValueSize getValueSize
Function Returns the size of the environmental variable in bytes. For environmental
variables of type string, the string length plus the terminating null charac
ter will be returned.
int varSize;
...
varSize = getValueSize(switch);
inport inport
Note The built-in constants LPT1, LPT2, and LPT3 can be used as a port address.
Example
...
val = inport(0x3f8); // Reads port 0x3f8
...
isExtId isExtId
Example
Passing the message ID as a parameter:
on message * {
if (isExtId(this.ID))
write(“Message with 29-bit identifier
received.”);
}
isStdId isStdId
Example
Passing the message ID as a parameter:
on message * {
if (isStdId(this.ID))
write(“Message with 11-bit identifier
received.”);
}
keypressed keypressed
Function This function returns the key code of a currently pressed key. If no key is
being pressed it returns 0. Only one key can be pressed at a time.
Parameters None
Returns Key code of pressed key. If the 8 lower bits do not equal 0, keypressed
returns the ASCII code of the next key in the keyboard buffer. If the 8 lower
bits do not equal 0, the 8 upper bits represent the extended key code (see
IBM PC Technical Reference Manual).
Example
variables {
msTimer mytimer; // timer
message 100 msg; // CAN message
}
on key F1 {
setTimer(mytimer,100); // start 100 ms
timer
write(“F1 pressed”); // output to write
window
}
on timer mytimer {
if(keypressed()) { // True if any key is
pressed
setTimer(mytimer,100); // restart timer
output(msg); // send while
keypressed
}
else {
write(“F1 let go”);
}
}
ltoa ltoa
Function The number val is converted to a string s. In this case, base indicates a
number base between 2 and 36. s must be large enough to accept the
converted number!
Returns none
Example
...
long z = 255;
char s1[9];
char s2[9];
ltoa(z, s1, 2); // binary
ltoa(z, s1, 10); // decimal
...
Result: s1 = 11111111, s2 = 255
mkExtId mkExtId
Example
...
msg.id = mkExtId(this.id);
...
outport outport
Returns none
Note The built-in constants LPT1, LPT2, and LPT3 can be used as a port address.
Example
...
outport (0x3f8, 12); // Outputs 12 to port 0x3f8
outport (LPT2, ‘x’); // Outputs ‘x’ to LPT2
...
output output
Function Outputs a message, an error frame, or a parameter group from the program
block onto the CAN bus.
Returns none
output(msg) Example
variables {
message can2.125 msg = { // declare CAN-Message
dlc = 1,
byte(0) = 1
};
}
on key F1 {
output (msg); // output Message to CAN 2
}
output(errorFrame) Example
on key F10 {
output(errorFrame); // output error frame to CAN1
}
output(pg) Example
variables {
pg DashDisplay dDisplay;
}
on key F9 {
dDisplay.FuelLevel.phys = 75;
output(dDisplay);
}
putValue putValue
Function Assigns the value val to the environment variable with identifier
EnvVarName. Integers are assigned to discrete environment variables,
floating point numbers are assigned to continuous environment variables, and
character strings are assigned to character string environment variables.
Returns None
Example
// Assign the value 0 to environment variable
“Switch”
putValue(Switch,0);
Compatibility This function has restricted compatibility. Please see the function
compatibility chart for more details.
random random
Example
...
dword randVal;
randVal = random(101); // Get a value 0..100
...
resetCan resetCan
Syntax resetCan();
Function Resets the CAN controller. Can be used to reset the CAN controller after a
BUSOFF or to activate configuration changes. Since execution of the
function takes some time and the CAN controller is disconnected from the
bus briefly, messages can be lost when this is performed.
Parameters none
Returns none
Example
on key ‘r’ { // Controller is reset when ‘r’ key is
pressed
resetCan();
}
Compatibility This function has restricted compatibility. Please see the function
compatibility chart for more details.
runError runError
Function Triggers a run error. Outputs the error number to the Write window indicating
the error number and the passed number, and then terminates the
measurement.
Parameters Numbers that are represented in CANalyzer as a references for the user.
The values under 1000 are reserved for internal purposes. The second
parameter is reserved for future expansion. Currently, the second parameter
can be any number.
Returns none
Example
...
if(rpm < 0) runError(1001,1);
...
seqFileClose seqFileClose
Function This function closes the file specified by the long integer fileHandle. The file
handle is assigned by the seqFileLoad() function. All buffers allocated by the
system are freed upon closing.
Returns The function returns zero with success. If the operation fails, it returns
non-zero error code.
fileHandle = seqFileLoad(“capl.dat”);
...
errorCode = seqFileClose(fileHandle);
if (errorCode == 0)
{
write(“File closed.”);
}
else
{
write(“Error number %d closing file.”, errorCode);
}
seqFileGetBlock seqFileGetBlock
Function The function reads at most bufferSize characters from the file specified
byhandle file into the array buffer. Newline characters are read into the
buffer.The file position indicator is advanced by the number of characters
successfully read.
Returns The return value is the number of characters successfully read, which may
be less than bufferSize if the end-of-file is encountered. The value is
negative when an error occurs.
fileHandle = seqFileLoad(“capl.dat”);
charsRead = seqFileGetBlock(buffer, 10,fileHandle);
if (charsRead >= 0)
{
write(“Characters read: %d”, charsRead);
}
else
{
write(“Error %d reading from file.”, charsRead);
}
seqFileGetLine seqFileGetLine
Function The function reads at most bufferSize-1 characters from the file with the
handle file into the array buffer. No more characters are read after a newline
character or after end-of-file. The function retains the newline character, but
the line is not null-terminated. A null must be placed into the character array
after the data if the buffer is to be used as a string.
Returns The number of characters successfully read, or a negative error code if the
operation fails.
fileHandle = seqFileLoad(“capl.dat”);
charsRead = seqFileGetLine(buffer, 100,fileHandle);
if (charsRead >= 0)
{
write(“Characters read: %d”, charsRead);
}
else
{
write(“Error %d reading from file.”, charsRead);
}
seqFileGetLineSZ seqFileGetLineSZ
Function The function reads at most bufferSize-1 characters from the file with the
handle file into the array buffer. No more characters are read after a newline
character or after end-of-file. The function retains the newline character, and
the line is terminated by a null character.
fileHandle = seqFileLoad(“capl.dat”);
charsRead = seqFileGetLineSZ(buffer, 100,fileHandle, 1);
if (charsRead >= 0)
{
write(“Characters read: %d”, charsRead);
write(“The line read: %s”, buffer);
}
else
{
seqFileLoad seqFileLoad
Function This function opens the file whose nameis the string pointed to by the
name.The file will be opened as read-only.
Returns The file handle. The return value is <= 0 if an error occurs.
Note The function searches the file in the path given by the SeqFilePath entry in
the [CAPL] section of the CAN.INI initialization file. If the entry does not
exist, the file is searched in the application directory (Exec/Exec32). Any
drive and path information provided in the parameter is ignored.
Example ...
long fileHandle;
fileHandle = seqFileLoad(“setup.txt”);
if (fileHandle <= 0)
{
write(“Error number %d opening setup.txt.”, fileHandle);
}
else
{
write(“setup.txt opened with file handle %d”, fileHandle);
}
...
seqFileRewind seqFileRewind
Function This function sets the file position indicator to the beginning of the file speci
fied by the handle file.
Parameters The file handle of the file to rewind. The handle is assigned by
seqFileLoad().
Returns The function returns zero if successful. If the operation fails, it returns anon-
zero error code.
fileHandle = seqFileLoad(“setup.txt”);
...
errCode = seqFileRewind(fileHandle);
if (errCode == 0)
{
write(“setup.txt rewind successful.”);
}
else
{
write(“Rewind failed.”);
}
setBtr setBtr
Function Sets the baud rate. The values do not become active until the next call of the
function resetCan().The function can also be used to automatically determine
the baud rate. It should be noted that these values depend on the CAN
controller used.
Returns none
Example
...
setBtr(0, 0x00, 0x3a); // 500 kBaud for 82C200
resetCan(); // activate
...
Compatibility This function has restricted compatibility. Please see the function
compatibility chart for more details.
setLogFileName setLogFileName
Parameters New name of the logfile. The name may be an absolute path or a single
filename. If a path is supplied, the path must exist prior to the start of the
simulation. If the path does not exist, the call to setLogFileName() will be
gnored. The logfile will be placed in the directory of the current configuration,
if a single filename is supplied. The directories of the path must be separated
by a double backslash (‘\\’). The filename must not contain a file extension.
The extension will be set automatically based on the type of log file (.ASC for
ASCII or .LOG for binary).
Returns none
Example
...
setLogFileName(“newlog”);
...
Set the name of the logging file to “newlog” in the directory of the current
configuration.
...
setLogFileName(“c:\\canw\\demo\\automot\\newlog”);
...
Set the absolute path of the logging file. The path c:\canw\demo\automot
must be created before the simulation begins.
Compatibility This function has restricted compatibility. Please see the function
compatibility chart for more details.
setMsgTime setMsgTime
Function Assigns to the message m1 the capture time of message m2 or the current
time. This function is obsolete and only serves to establish compatibility with
older versions.
Parameters Variable of type message and another variable of type message or “now”.
Returns none
Note This function has been made obsolete by the TIME message selector. See
the section on message selectors for more information.
setOcr setOcr
Function Sets the CAN controller’s Output Control Register. The values do not become
active until the next call of the function resetCan().
It should be noted that these values depend on the CAN platform used.
Returns none
Example
...
setOcr(0, 0x02); // set
resetCan(); // activate
...
Compatibility This function has restricted compatibility. Please see the function
compatibility chart for more details.
setPostTrigger setPostTrigger
Function Set the posttrigger of the logging. The posttrigger set with this function is
valid until the end of the measurement or until the next call of this function.
Example
// Set the posttrigger time of the logging to 2.5 seconds.
...
setPostTrigger(2500);
...
Compatibility This function has restricted compatibility. Please see the function
compatibility chart for more details.
setPreTrigger setPreTrigger
Function Set the pretrigger of the logging. The pretrigger set with this function is valid
until the end of the measurement or until the next call of this function.
Example
...
setPreTrigger(25);
...
Set the pretrigger time of the logging to 25 milliseconds.
Compatibility This function has restricted compatibility. Please see the function
compatibility chart for more details.
setTimer setTimer
Function Set a timer, which can be either Timer type or msTimer type.
Parameters Variable of type Timer or msTimer and the duration of the timer in units of
seconds or milliseconds, respectively.
Returns None
Example
variables {
Timer t1;
}
on start {
setTimer(t1, 5); // Initialize a 5-second cyclic timer
}
on timer t1 {
. . .
setTimer(t1, 5); // Reset timer for another 5 seconds
}
sin sin
Returns Sine of x
Example
double x;
x = sin(PI); // x equals 0, PI is a built-in
constant
double tangent(double x) {
return sin(x) / cos(x);
}
snprintf snprintf
Parameters Similar to the write() function, this function can take a variable number of
arguments. There should be an additional parameter after the format
parameter for each of the string formatting expressions used in the format
string. The string formatting expressions are the same used for the write()
function and are listed here:
Example
char infoStr[100];
int vol = 55;
byte bal = 3;
long res;
Compatibility This function has restricted compatibility. Please see the function
compatibility chart for more details.
sqrt sqrt
Example
double x;
x = sqrt(4.0); // Result 2.0
stop stop
Syntax stop();
Parameters none
Returns none
Example
...
if( isExtId(this) )
stop(); // End measurement if we find an extended
ID
...
strlen strlen
Example
...
length = strlen(“CANalyzer”);
...
Result: length = 9
strncat strncat
Function This function appends src to dest. The function ensures that there is a
terminating ‘\0’ in the dest string. Thus, a maximum of len- 1 characters are
copied.
Example
...
string s1 = {“Vector”};
string s2 = {“CANalyzer”};
strncat(s1,s2,16);
...
Result: s1 = “VectorCANalyzer”
strncmp strncmp
Returns -1 if s1 < s2
0 if s1 = s2
1 if s2 > s1
Example
...
if(strncmp(s1, s2, strlen(s1))
write(“not equal”);
else
write(“equal”);
...
strncpy strncpy
Function This function copies src to dest. len indicates the maximum length of src and
dest. The function ensures that there is a terminating ‘\0’. Thus, a maximum
of len-1 cahracters are copied.
Example
...
string s1 = {“Vector”};
string s2 = {“CANalyzer”};
strncpy(s1, s2, strlen(s2) + 1);
...
Result: s1 = “CANalyzer”
swapDWord swapDWord
swapInt swapInt
swapLong swapLong
swapWord swapWord
sysExit sysExit
Syntax sysExit();
Function Exits the system (CANalyzer or CANoe) from within a CAPL program.
Parameters none
Returns none
Example ...
sysExit();
...
Compatibility This function can only be used in P-Blocks in CANalyzer’s analysis branch or
in CANoe’s Measurement Setup window.
sysMinimize sysMinimize
Syntax sysMinimize();
Parameters none
Return none
Example ...
sysMinimize();
...
Compatibility This function can only be used in P-Blocks in CANalyzer’s analysis branch or
in CANoe’s Measurement Setup window.
timeDiff timeDiff
Function Time difference between messages or between a message and the current
time in ms (msg2 - msg1 or now - msg1).
Note Starting with CANalyzer 2.0, this difference can be calculated directly using
the TIME message selector. See the section on message selectors for more
details.
Parameters A variable of type message as the first parameter, and then another
message variable or “NOW” as the second parameter.
timeNow timeNow
Parameters none
Returns Time since the start of the current measurement in units of 10 µsec. This
time is established with the help of the PC timer with a resolution of 1 msec.
Message times determined by the CAN PC-card have greater precision and
are therefore not directly comparable to timeNow().
Example
...
float x;
x = timeNow()/100000.0; //current time in seconds
...
trigger trigger
Syntax trigger();
This function is not allowed in all CAPL blocks. It can be used in program
blocks and as CAPL trigger.
Parameters none
Returns none
valOfId valOfId
Example
...
id = valOfId(this); // works with ext-id as well
...
write write
Function Outputs a text message to the Write window. Write is based on the C
function “printf”.
The compiler cannot check the format string. Illegal format entries will lead
to undefined results.
Parameters The write() function allows a variable number of parameters. The format for
the parameters is a format string containing string formatting expressions
followed by zero or more arguments, each of which corresponds to one of
The string formatting expressions are shown below:
Returns none
Example
void display() {
int i = 10;
int j = 25;
writeToLog writeToLog
Function Writes on output string to an ASCII logging file. Write is based on the C
function “printf”. Data is only written to a log file when logging is enabled in
CANalyzer or CANoe. A call to this function is ignored when logging is
disabled. The compiler cannot check the format string. Illegal format entries
will lead to undefined results.
Returns none
Example
void MarkLogFile(int marker) {
// marks line of ASCII logging file with an
integer
writeToLog(“===> %d”, marker);
}
Note that the 0.000 indicates the time since the start of the simulation that
the log file entry was made in units of seconds.
Compatibility This function has restricted compatibility. Please see the function
compatibility chart for more details.
In this chapter, we will show examples of common programming tasks with CAPL. It is a good
idea to skim through the examples in this section to become familiar with what it contains so you
can refer to it later as a reference. Some examples build on examples and ideas from other
sections, so you might need to refer to more than one section to get a complete answer to your
question.
Now, to send a message, we only need to put one of these lines into an event procedure:
output(msg1);
output(msg2);
Of course, we can also add data to the message before we send it. The EngineData message
has signals defined in the database, but the other message does not. Therefore, we have to use
two different methods to add data to the messages.
msg1.EngSpeed.phys = 1000;
msg1.EngTemp.phys = 150;
msg1.IdleRunning = 1;
output(msg1);
Notice that the phys modifier was used on msg1’s signals, because they had conversion formulae
defined in the associated database. The phys modifier was not used on the IdleRunning signal
because it is a one-bit signal with no conversion formula defined.
Statements like these (assigning data to messages and using output() to send them) can be
used in most event procedures, such as:
on key someKey { . . . }
on envVar someVar { . . . }
on message someMsg { . . . }
on errorFrame { . . . }
on Timer someTimer { . . . }
on start { . . . }
To define an event procedure, you must first select the corresponding category in the Event
Types window (upper left corner). Then, right-click in the Event Procedures window and select
New from the menu. Refer to the chart in the Events section of the manual for a list of event
types and corresponding event procedures.
. . .
}
Next, we need to initialize the timer in the start event procedure. If you do not yet have a start
event, select System from the Event Types window (upper left corner). Then right-click in the
Event Procedures window (lower left corner) and select Start from the New submenu. You will
see the on start event procedure created in the Event Procedure window (lower right corner).
After you are in the on start event procedure, you should add a setTimer command to
initialize the timer for the first time. If you do not do this, the timer event never occurs. Also,
make sure to use the global variable containing the period (timerPeriod in this case) with the
setTimer() function instead of the actual value (100 in this case).
on start {
. . .
setTimer(periodicTimer, timerPeriod);
. . .
}
As soon as the timer is set, it is activated and begins to count down. When the count reaches
zero, the corresponding on timer event procedure is executed. We need to create this event
procedure now. In the Event Types window (upper left corner), select Timer. Then, right-click in
the Event Procedures window (lower left corner) and choose New. In the Procedure Editing
window (lower right corner), you will see that a skeletal event procedure has been created.
To write your own event procedure, first replace the <newTimer> string with the name of the
timer you have declared (periodicTimer in this case). Then, write the code to send the message
in the body of the procedure. Finally, add a setTimer function call at the end of the body of code.
on timer periodicTimer
{
// We can send out whatever data we want here.
msg.byte(0) = 6;
output(msg);
on buttonStatus
{
int val;
val = getValue(this); // Get the value of buttonStatus
if (val == 0)
{
// Going from “on” state to “off” state
cancelTimer(periodicTimer);
}
else
{
// Going from “off” state to “on” state
setTimer(periodicTimer, timerPeriod);
}
}
Since this event procedure is executed when the value of buttonStatus changes, we are either
changing from a “on” state to an “off” state or vice versa. Going to the “on” state means setting
the periodic timer so that the timer event procedure, which actually sends the periodic message,
is executed. While we remain in the “on” state, the timer event procedure resets the timer every
time it executes. Going to the “off” state means stopping the timer so that the timer event
procedure is not executed until we change states again.
As a final note, we also need to make sure that the system is initialized in the correct state. For
example, if the button is being held down while the system is started, we will not execute an
environmental variable event procedure until the button is released. Therefore, we could miss an
entire button press, no matter how long the button is held down. We also do not want to set the
timer in the on start event procedure like we did for a normal periodic message, because that
implies that the button is depressed when the system is started.
Using the CallAllOnEnvVar() function in the on start event procedure gives us the desired results.
CAPL provides this function for use in initialization routines to allow us to check the values of
environmental variables. CallAllOnEnvVar() executes the event procedures for every
environmental variable that has an event procedure defined. Using this, we will be able to
determine the state of the button at startup and act accordingly. Our on start event procedure
now looks like this:
on start {
. . .
// The setTimer() call is no longer used here.
CallAllOnEnvVar();
}
Once you have created the on message event procedure, any code that you wish to execute in
response to this message should go in the body of the event procedure. You could send out
another message or print the a message to the screen:
on message ABSdata, EngineData
{
message WheelInfo wMsg; // Define a new message
long product;
Note the use of the “phys” modifier to ensure that conversion formula defined in the database are
used to get the true values of the speed and temperature.
Alternately, you can access the raw bytes of data in the message received. This is a quick way to
access messages with simple structures or to copy blocks of data from one message to another.
Suppose that the EngineTemp message was defined as having one byte of data and we did not
define any signal names for it in the database. We could then create this on message event
procedure:
on message EngineTemp
{
byte value;
float temp;
value = this.byte(0);
Since we did not define a signal for this byte of data, there is no conversion formula and we
cannot use the “phys” modifier. This is important to remember — if the number needs to be
scaled or otherwise adjusted, you need to do it yourself when accessing raw data bytes.
Next, we need to create the message event procedure which sets the timer if the doors are
closed. In the Event Types window (upper left corner), select CAN-Message. Then, in the Event
Procedures window (lower left corner), right-click and select New. You should see a skeletal
message event procedure in the Procedure Editing window (lower right corner). For this
example, we will change the string <newMessage> to doorState:
on message doorState {
if (this.Closed == 1)
setTimer(delayTimer, delayTimerPeriod);
else
{
. . . // Do this if doors are open
}
}
Finally, we will create the timer event procedure which will actually turn off the light five seconds
later. In the Event Types window (upper left corner), select Timer. Then, in the Event
Procedures window (lower left corner), right-click and select New. You should see a skeletal
timer event procedure in the Procedure Editing Window (lower right corner). For this example,
we will change the string <newTimer> to delayTimer:
on timer delayTimer
{
message DomeLight dlMsg;
dlMsg.Status = 0; // Turn off dome light
output(dlMsg);
}
For example, if we wanted to send an error frame every time the “e” key was pressed, we could
define an on key event procedure. To do this, select Keyboard in the Event Types window
(upper left corner). Then, right-click in the Event Procedures window (lower left) and choose
New. You should then see a skeletal event procedure in the Procedure Editing window (lower
right corner). Replace the string <newKey> with the character that we wish to make the event
occur (in this case, ‘e’). Then, simply add the line mentioned above to the body of the event
procedure.
{
output(errorFrame);
}
// Make a noise.
beep();
Recall that if more than one specifier matches a keystroke, only the best matching event
procedure is executed. So if the above event procedures were all defined and the user pressed
the “j” key, the event procedure would be executed, but the on key * event
procedure would not.
Inside the event procedure itself, you can write any legal CAPL code. For example, you could
print a message to the Write window, send a message on the bus, or increment a variable’s
value.
lastTime = this.TIME;
}
The TIME message selector returns the time since the current simulation was started as a long
integer in units of 10 microseconds. Therefore, we divide the value by 100 to get the time in
milliseconds. Since all of CAPL’s procedure variables are static, the lastTime variable retains the
value of the time the last message was received from the last time this procedure was called.
The second method of calculating the time between periodic messages is to use CAPL’s
timeDiff() function. This function can either take two messages as parameters or one message
and the keyword NOW.
In order to use the function, we will need to save a copy of the last periodic message received. In
this example, the we are looking for message 202 hex, so we will declare one instance of the
message globally in the Global Variables window (upper right):
variables {
message 0x202 saveMsg;
. . .
}
Then, we will create the on message event procedure. First select CAN-Message in the Event
Types window (upper left corner). Then right-click in the Event Procedures window (lower left
corner) and choose New. You should then see a skeletal event procedure in the Procedure
Editing window (lower right). We replaced the string <newMessage> with 0x202 and entered this
code:
on message 0x202
{
write(“Message 0x202 received at % this.TIME);
write(“Time interval = %ld milliseconds”,
timeDiff(saveMsg, this));
The major differences when using the timeDiff() function is that you work with whole message
objects (instead of just one variable) and that it automatically converts the units to milliseconds.
Pragmatically, the timeDiff() function has been made obsolete by the TIME message selector.
You can put any legal CAPL code into the body of this procedure. In this procedure, you might
want to activate logging, call the stop() function, or print a message to the Write window.
You can put any legal CAPL code into the body of this procedure. In this procedure, you might
want to activate logging, call the stop() function, or print a message to the Write window.
You can put any legal CAPL code into the body of this procedure. In this procedure, you might
want to activate logging, call the stop() function, or print a message to the Write window.
Of course, you could substitute any code for the writeToLog() calls. Also, you do not have to
output the messages to the opposite CAN channel — there are many possibilities for this
configuration.
variables {
// Env. variable button1 declared in database
The DialMsg has been configured in the database to hold one 8-bit signal containing the position
of a dial. The dial1 message, which is not defined in the database, will also hold one byte of data.
Since the environmental variables are declared in the database, we do not declare them in CAPL.
Next, we need to set up the on start event procedure to start the timer for the first time. We use
the maxMsDelay and minMsDelay values in conjunction with the random() function to get a
number in our desired range. Note that random() returns a value between 0 and one less than
the argument. To create an on start event procedure, select System in the Event Types window
(upper left corner). Them right-click in the Event Procedures window (lower left corner) and
select New. You should then see a skeletal event procedure in the Procedure Editing window
(lower right corner).
on start {
int delay; // Delay until first input
. . .
delay = random(maxMsDelay - minMsDelay) + minMsDelay;
setTimer(randomTimer, delay);
}
The timer event procedure is where most of the work happens. The event procedure must first
decide which input to change, then change the input, and then reset the timer to a random value.
To create the event procedure, first click on Timer in the Event Types window (upper left corner).
Then, right-click in the Event Procedures window (lower left corner) and choose New. You
should then see a skeletal event procedure in the Procedure Editing window (lower right corner).
Make sure to change the string <newTimer> to randomTimer.
on timer randomTimer
{
int input; // Random value for picking input
int delay; // Delay until next input
switch (input)
{
case 0:
// Toggle button1 (either 0 or 1)
write(“Toggling button1”);
putValue(button1, abs(getValue(button1) - 1));
break;
case 1:
// Change value of dial1 from 0..1000
write(“Changing value of dial1”);
dial1.byte(0) = random(1001);
output(dial1);
break;
case 2:
// Change value of dial2 from 0..1000
write(“Changing value of dial2”);
dial2.position.phys = random(1001);
output(dial2);
break;
}
If you experiment with the code shown above, you will see that its easy to control the nature and
randomness of the inputs. In case 0, the value of an environmental variables is changed. In
case 1, a message that is not defined in the database is used to transmit the new dial value. In
case 2, a database-defined message is used to transmit the new dial value.
on message 0x101
{
// Set the PreTrigger time to 1 second (1000 ms)
setPreTrigger(1000);
// Trigger logging.
trigger();
Also note that CAPL programs using the logging functions described above cannot be compiled
from the CAPL Browser, since the Browser does not know where the P-Block containing the code
will be placed. Therefore, you must first place and configure the P-Block containing the CAPL
program in CANalyzer or CANoe, then compile the CAPL program from the CANalyzer or
CANoe’s Configuration menu by selecting “Compile All Nodes”.
You can put any legal CAPL code in the body of the procedure, so there are several choices for a
reaction to the change of the environmental variable. However, you will almost always want to
read the value of the environmental variable. This is accomplished using the getValue() function.
This function can return an integer, floating point number, or a string (refer to the section on
environmental variables for more details). In this case, we have declared switchState as an
integer in the database, so we will read an integer value from it and respond accordingly.
on envVar switchState
{
int switchValue;
switchValue = getValue(this);
switch (switchValue)
{
case 0:
write(“Switch is now off.”);
break;
case 1:
write(“Switch is now on.”);
break;
default:
write(“Switch returned an illegal value.”);
break;
}
}
Note that in this case, only the values 0 and 1 are legal. In your system, an environmental
variable could have thousands of states.
As a final note, CAPL provides a function called CallAllOnEnvVar() which should be used during
initialization. This function executes every environmental variable event procedure that you have
defined. This allows you to determine the states of all of the environmental variables at the start
of the measurement and react accordingly. Otherwise, you would have to wait until the value of
each environmental variable changes to respond to its state.
We can place this function call into the on start event procedure by selecting System in the Event
Types window (upper left corner). Then right-click in the Event Procedures window (lower left
corner) and select Start from the New submenu. You should then see the on start event
procedure in the Procedure Editing window (lower right corner). You can insert the
CallAllOnEnvVar() call anywhere in the body of the procedure.
on start
{
. . .
CallAllOnEnvVar();
}
J1939 is a protocol that is built on top of the CAN protocol. The main differences are the manner
that the identifier field’s bits are partitioned and the predefined identifier names.
If you intend to program for a J1939 network with CAPL, you should be familiar with J1939
parameter groups (or “pgs”) and understand the differences between pgs and normal CAN
messages.
to output onto the bus the parameter group with parameter group number 0xFEF1 (hex) as well
as the parameter group RetarderConfig as defined in an associated database.
Parameter group names can be selected using the right mouse button pull-down menu in the
CAPL Browser once a J1939 database is associated. The method is the same as selecting a
message name for a normal CAN database.
Selector Usage
PGN Parameter group number
SA Sender of the parameter group
DA Receiver of the parameter group
PF PDU format
PS PDU specific
Characteristic Priority, data page and reserved bit of the
parameter group
When initializing a parameter group within the definition, the following supplemental attributes are
also available:
Selector Usage
PRIO Priority of the parameter group
You can use these selectors to define parameter groups in your CAPL code. For example, with
pg TC1 pg_tc1 = {
SA = 0x34, // Sender
DA = 0x24 // Receiver
};
output(pg_tc1);
you would define and send the parameter group TC1 (PGN = 0x100) from the station with
identification 0x34 to station 0x24.
Components of the objects are accessed by Component selectors. If you wish to define the object
for a certain chip (for CAN cards with more than one CAN chip), you would prefix the appropriate
selector (CAN1 or CAN2) followed by a dot (.).
No selector is provided for changing the length of a parameter group (DLC).
if (pg.pgn == TC1) {
// If the received parameter group is TC1
// Transfer the received parameter group to the
variable
getThisMessage(pg_tc1, pg_tc1.dlc);
}
INDEX
enum 24
Symbols CANdb database 22
Environmental Variable 168
CAPL Browser 46
* 34, 37 Environmental variable 55
CAPL Programming
. 23, 27 environmental variable
Environment 3
.CAN file 58 17, 42, 50, 155
case 14
.CAN Files 12 Environmental Variables 32
char 25
.CBF File 12, 58 error active 39
Characteristic 170
:: 22 Error Frame 159, 160
Comments 14, 59
Error frame 55
Compile 51, 58
error frame 42
Component selectors 171
Error Passive 163
A Constants 23, 33
error passive 39
continue 14
errorCountRX 40
abs 74 CONTROL 172
errorCountTX 40
Analysis Branch 66 conversion formula 29, 157
Errors
Analysis Branches 66 cos 81 CAN bus 39
Arrays 19 Compilation 58
Multidimensional 19, 25 Round-off errors 29
arrays 172 Routine 51
atol 75 D Run-time 20, 58
DA 170 Evaluation Branch 43, 65
Data Length Code 30, 172 Event
Categories 55
B data length code 27 on errorActive 35
Data page 171 on key 35
beep 76 Database 59 on message 35
beep() 160 Associated on start 35
Binary File 58 26, 27, 48, 50, 168 on stopMeasurement 35
Binary Files 12 associated 22, 23 event procedure 34, 153, 155
break 14 J1939 172 Event Procedures 56
Browser 46 database 23 event procedures 32, 34
bus off 39 Database Assiociated 21 Event Prodcedures Window 47
byte 25, 31 default 14 Event table 5
DIR 30 Event Types Window 47
DISCRETE 172 Event Types window 55
DLC 27, 30, 172 Events 13, 34
C double 25 cyclic 41
C 13, 18, 20, 25 DP 171 envVar 35
CAPL equivalents 20 dword 25 Event procedures 13
Standard syntax 14 Dynamic memory 19 on busOff 35, 39
CallAllOnEnvVar() 39, 156, 169 on envVar and on envVar 42
CAN 30 on errorActive 39
CANBROW.EXE 46 on errorFrame 35
cancelTimer 78 E on errorPassive 35, 39
cancelTimer() 155 elCount 82 on key 37
CANdb 21, 23, 26 elCount() 19 on message 36
ellipse 14
else 14
INDEX
on pre Start 35
on start 39 H
on stopMeasurement 39 M
on time 41 Help menu 52
on timer 35, 41 hex 24 malloc() 19
on warningLimit 35, 39 hexadecimal 14 Menus
preStart 39 File 48
Procedures 56, 57 Message 26, 55
Sending an Event Message 152 Received 156, 157
Exit 49 I Responding 158
exp 83 message 17, 25, 152
extended CAN ID 27 ID 30 Message identifier 30
if 14 Message selectors 30
inport 102 message selectors 27
inport() 33 Messages 50
F int 25 Accessing raw data 31
integer 24 Periodic 153
Factor 29 isExtId 103 Repetitive 155
File menu 48 isStdId 104 messages 12, 32
fileName 84
pass-through 43
fileReadArray 85
mkExtId 107
fileReadFloat 87
msTimer 25, 26, 41
fileReadInt 88 J multidimensional arrays 19
fileReadString 89
fileWriteFloat 90 J1939 170
fileWriteInt 91 J1939.DBC 172
fileWriteString 92 N
Find 50
float 24, 25 naming convention 13
K notation 13
Function Compatibility 65
Functions 13, 50 Keyboard Inputs 160 NOW 162
built-in 13 Keypress 55
User-Defined Functions 13 keypressed 105
functions 16 keystrokes 37
Functions overloading 16 O
Funtions Object
User-defined 55 Message 26
L Parameter Groups 170
Objects
log files 45 messages 27
G logging 44, 167 msTimer 26
long 25, 31 Timer 26
getCardType 93 loops 14 Types 25
getChipType 95 LPT1 33 Offset 29
getLocalTime 96 LPT2 33 on BusOff 55
getThisMessage 99 LPT3 33 on busOff 162
getThisMessage() 172, 173 ltoa 106 on busOff events 39
getValue 100
on envVar 153, 168
getValue() 17, 33, 42, 155
on errorActive 39, 55, 163
Global
Variables 54 on errorFrame 153, 160
Global Variables Window 47 on errorPassive 39, 55, 163
Global Variables window 54 on key 153, 160
on key event 37
INDEX
on message
36, 153, 157, 158, 163, 167
on preStart 39, 55
R Source Code 59
on start 39, 153, 154, 156, 169 random 111 source file 58
on stopMeasurement 39 Random Inputs 164 SPECIFIC 172
on Timer 153 random() 164, 165, 166 sprintf 20
on timer 154, 159, 166 RANGE 172 sqrt 132
on warningLimit 39, 55 raw data access 32 static 18
onpreStart 55 raw value 29 stop 133
onstart 55 Real-Time Branches 66 string 24
onstopMeasurement 55 Receive 30 Strings
Options 52 constants 25
Remote Transmission Request
outport 108 strlen 134
30
outPort() 160 strncat 135
Replace 51
outport() 33 strncmp 136
resetCan 112
output 109 strncpy 137
return 14
output() swapDWord 138
RTR 30
32, 152, 157, 159, 170, 173 swapInt 139
Run-time errors 20
Ox 14 swapLong 140
run-time errors 58
swapWord 141
runError 113
switch 14
runError() 20, 58
symbolic identifiers 22
runtime error 51
P symbolic name 27
RX 30
symbolic names 21
P-Block 43, 46 RXDATA 31
symbolic signal access 29
P-Blocks 43, 65 RXREMOTE 31
symbolic signal values 22
pass-through 43
parameter group 170
parameter group number 170
parameter groups 170 S
T
parameters 16, 34 SA 170
pass-through 43 text editor 12
Saving files 48
Periodic Message 153 Text Editors 59
setBtr 122
PF 170 this 17, 35, 38, 40, 42
setLogFileName 123
pg 17, 25 TIME 30
setLogFileName() 45, 167
PGN 170 timeDiff 144
setLogFilleName() 65
pgs 170 timeNow 145
setMsgTime 124
phys attribute 29, 152, 157 Timer 25, 26, 41, 55, 158
setOcr 125
Physical values 29 timer 153
setPostTrigger 126
PI 33 timers 12
setPostTrigger() 45, 167
posttrigger time 45 Tool bar 47
setPreTrigger 127
precedence rules 36 toolbar 53
setPreTrigger() 45, 167
pretrigger time 45 Transmission Branch 65, 66
setTimer 26, 128
printf 20 Transmit 30
setTimer() 41, 154, 155, 165
Printing 49 Transmit Request 30
signal names 32
PRIO 171 trigger 146
signal values 29
priority 171 Trigger Type 44
Signals 26, 50
Procedure Editing 57 trigger() 45, 167
signals 27
Procedures 16 TX 30
SIMULATED 30
Prodedure Editing Window 47 TXDATA 31
Simulation Setup Window 66
PS 170 TXREMOTE 31
sin 129
putValue 110 TXREQUEST 30
sizeof 20
putValue() 32 TXREQUESTDATA 31
snprintf 130
INDEX
TXREQUESTREMOTE 31
TYPE 30, 31 X
Type casting 14
x 14, 27
U
Undo 50
User-Defined Attribute 24
user-defined attributes 23
User-defined function 55
V
valOfId 147
Variable 12
Global Variable Declarations
12–45
Types 25
Variables 50
Default values 20
Environmental 32
Variables Local 18
Variables Static 18
W
Window
Event Types 55
Events 55
Measurement Setup 65
Simulation Setup 65
Windows
Event Procedures 47, 56
Event Types 47
Global Variables 47, 54
Measurement Setup 66
Procedure Editing 57
Prodedure Editing 47
Simuation Setup 66
word 25, 31
write 148
Write window 20, 58
write() 157, 158
writeToLog 150