Hello Readers,
My name is Rajesh M, and I work at Luxoft India as a Junior Software Developer. Luxoft has given me several opportunities to work on various projects, which has inspired me to learn the essential processes involved in developing AUTOSAR Modulеs and Add-Ons in INTRODUCTION TO CAPL PROGRAMMING.
INTRODUCTION
CAPL is the most used programming language in the automotive world for developing automated tests and simulations. It is the primary programming language for the most powerful CAN tools offered by Vector.
The programming language is based on C/C++ syntax and offers some key features for embedded systems to the programmers. CAPL developers can develop fully automated simulations in CAPL by developing automated test environments for their systems.
CAPL and the corresponding Vector tools offer:
- manage test scenarios and all test activities
- event-based functions used in simulations or tests
- interconnections with other PC applications
CAPL is event-driven software, because running a test script or simulation cannot be considered linear execution. The program can switch to another procedure at any time based on three different types of events.
The CAPL browser, where full autotest or autosimulation development is performed, has a very useful text editor for the CAPL program, as well as a CAPL compiler.
A program written in CAPL represents parts or all the behavior of a single network node of a car. For more complex systems and simulations, the programmer can create several different nodes connected to the same CAN bus, each node running its own CAPL software. All nodes can be simulated to check the behavior. Once this is done, the developer can deactivate any bus node and connect it to the real system for testing. In addition to running a generic CAPL program.
most tools also provide other useful functions for testing and debugging embedded systems.
- accurate and easy to use trace window
- bus statistics
- graphic display of sent/received messages and signals
- logging / replay capabilities
Advantages of CAPL Programming:
The system environment can be copied using CAPL, for example by simulating the data traffic of all other network nodes.
Node or system behavior using readable English instructions and values instead of hexadecimal values.
Event messages, periodic messages, or conditionally repetitive messages.
Human events like button presses on the PC keyboard.
Timed node or network events.
Multiple time events, each with its own programmable function.
Normal operation, diagnostic operation, or manufacturing operation.
Changes in physical parameters or symbolic values (for example, “ON”, “OFF”).
Module and network faults to evaluate a limited operation strategy.
A CAPL program consists of two parts:
- Declare and define global variables
- Declare and define user-defined functions and event procedures
CAPL Program Organization:
CAPL programs have three distinct parts:
- Global Variable Declarations
- Event Procedures
- User-Defined Functions
CAPL Variables:
The data types of variables are integers (dword, long, word, int, byte, char), floating point numbers (floating point and double numbers),
CAN messages (message) and timers (timer or msTimer). All other variables except timers can be initialized in their declarations.
example:
variable
{
int msgCount;
message 34 sendMsg = { dlc = 1, byte(0) = 1 }
}
Variables can be initialized after they are declared, in which case you can use either the plain notation or the braces {}. Except for timers, the compiler initializes all variables to their default values (unless otherwise specified: 0).
CAPL allows you to define arrays (arrays, vectors, matrices) analogously to how they are defined in the C programming language.
Example:
variable
{
int vector[5] = {1,2,3,4,5};
char progname[10] = “CANoe“;
}
Time events are created using variables of type timer (based on seconds) or msTimer (based on milliseconds). Timer variables are not automatically initialized when the program is started, but must be "set" specifically with the setTimer() function.
Example:
variable {
timer delayTimer;
msTimer cycTimer;
}
...
setTimer(delayTimer,3);
setTimer(cycTimer,100);
...
Declaration of Messages:
Messages printed by the CAPL program are indicated by the keyword message. The full statement contains the message identifier or, when working with symbolic databases, the message name. For example, the following message can be written to bus output message with an identifier of A (hex) or 100 (dec), or to a message defined in the EngineData database.
example
message 0xA m1; // Message declaration (hex)
message 100 m2; // Message declaration (dec)
message EngineData m3; // Symbolic declaration
message * wcrd; // Declaration without Id
...
output(m1); // Transmit message m1
output(m2); // Transmit message m2
output(m3); // Transmit message m3
wcrd.id = 0x1A0; // Define Id...
output(wcrd);
The control data of CAN message objects can be accessed with the following component selectors:
ID Message identifier
CAN Chip number
DLC Data Length Code
DIR Direction of transmission, possible values: RX, TX,
TIME Time point, units: 10 microseconds
Event Procedures:
You can use event procedures to respond to the following CAPL events
React to Changes in Values of Environment Variables
The "on envVar" event is caused by a change in the value of an environment variable. (Note: Remember that environment variables are only available in CANoe.) The "this" keyword is used with the getValue() function to get the value of an environment variable.
example:
on envVar Switch {
int val;
val = getValue(this);
}
CONCLUSION
In This Article I have Covered About Introduction to CAPL Programming And its Importance Thank you.
Top comments (0)