Setting Up the Development Environment
Use an isolated CANoe Simulation Setup configuration. Menus, shortcuts, encoding support and license requirements vary by release; follow the installed help. This walkthrough has not been executed by the site, and the outputs below are illustrative expectations.
Learning Objectives
After completing this article, you will be able to:
- Understand the basic structure of CANoe projects
- Familiarize yourself with the CAPL Browser interface layout and core functions
- Independently create, write, and compile a CAPL program
- Add CAPL nodes to the simulation environment and run them
Preparation
Before we begin, please ensure you have installed CANoe. If you haven't installed it yet, please contact your IT department or obtain a trial version from the Vector website.
What is a CANoe Project?
A CANoe project (.cfg file) is the container for all your work. It contains:
- Network configuration: Defines which buses are used (CAN, LIN, FlexRay, etc.)
- Database:
.dbcfiles that define the meaning of messages and signals - Simulation nodes: Your CAPL programs will run as simulation nodes
- Test configuration: Automated test modules and test cases
You can think of a CANoe project as a "virtual car" - it contains various ECUs (simulation nodes) that communicate with each other through buses (networks).
Getting to Know CAPL Browser
CAPL Browser is the Integrated Development Environment (IDE) for CAPL. You will write, compile, and debug all CAPL code here.
Opening CAPL Browser
There are two ways to open CAPL Browser:
Method 1: From CANoe main interface
- Open a CANoe project
- Select
View→CAPL Browserfrom the menu bar
Method 2: From a simulation node
- In the
Simulation Setupwindow, double-click a CAPL node - CAPL Browser will automatically open the node's source code
CAPL Browser Interface Layout
After opening CAPL Browser, you will see the following core areas:
| Area | Function |
|---|---|
| Ribbon | Top toolbar containing file operations, compilation, debugging, and other functions |
| Text Editor | Central area for writing CAPL code |
| Navigator | Left panel for quickly jumping to functions and events in the code |
| CAPL Function Explorer | Right panel showing all available CAPL functions |
| Symbol Explorer | Displays messages and signals defined in the database |
| Output Window | Bottom area showing compilation results and error information |
Ribbon Functional Areas
CAPL Browser's Ribbon is divided into several main tabs:
- File: File operations (New, Open, Save)
- Home: Compilation, editing tools, environment import
- Filter: Filter displayed functions and symbols
- Debug: Breakpoint management, runtime error checking
Among these, the Home tab is what you'll use most frequently, especially the Compile button.
Hands-On Practice: Hello, CANoe!
Now, let's create your first CAPL program together!
Step 1: Create a New CAPL File
- In CAPL Browser, click the
Filetab - Click the
Newbutton - Select
CAPL File - The system will open a new blank tab page in the editor
At this point, you'll see a blank editing area ready to accept your code.
Step 2: Write Your First Event
Enter the following code in the editor:
on key 'a'
{
write("Hello, CANoe!");
}
Let's understand this code line by line:
on key 'a' // When the user presses the 'a' key on the keyboard
{
write("Hello, CANoe!"); // Print this message to the Write window
}
on key 'a': This is an event handler, meaning "when the 'a' key on the keyboard is pressed"write(): This is CAPL's built-in function for outputting text to CANoe's Write window
Step 3: Save the File
- Press
Ctrl + Sor click the save icon in the toolbar - Choose a save location (recommended to save in the CANoe project directory)
- Enter a filename, such as
HelloWorld.can
Tip: CAPL source files have the
.canextension, and after compilation, a.cbffile (CAPL Binary Format) will be generated.
Step 4: Compile the Program
- Click the
Compilebutton in theHometab (or pressF9) - Check the
Output Windowat the bottom
If everything is normal, you'll see output similar to this:
Compiling HelloWorld.can...
0 error(s), 0 warning(s)
Continue only after your own compiler reports success; save its actual diagnostics.
Step 5: Add CAPL Node to Simulation Environment
Successful compilation is only the first step. To make the program actually run, you need to add it to CANoe's simulation environment:
- Return to the CANoe main interface
- Open the
Simulation Setupwindow (View→Simulation Setup) - Right-click in the network node tree and select
Insert Network Node - In the dialog that opens, browse and select the
HelloWorld.canfile you just saved - Click OK, and the node will appear in the simulation environment
Step 6: Run and Test
- Ensure the Write window is open (
View→Write) - Click the
Start(Start Measurement) button in the toolbar, or pressF9 - Press the
akey on the keyboard - Observe the Write window
You should see:
Hello, CANoe!
If your Write window shows this line after the key event, record the tool version and configuration that produced it.
Troubleshooting Common Issues
During this process, you may encounter some problems. Here are the most common situations and solutions:
Issue 1: Compilation Error
Phenomenon: Output Window shows red error messages.
Troubleshooting steps:
- Double-click the error message, and the editor will automatically jump to the erroneous code line
- Check if the syntax is correct (brackets match, semicolons not missing)
- Ensure strings use English double quotes
", not Chinese quotation marks
Common error examples:
// Wrong: Missing semicolon
write("Hello")
// Correct:
write("Hello");
Issue 2: Key Has No Response
Phenomenon: Pressing the a key produces no output in the Write window.
Troubleshooting steps:
- Confirm that measurement has started (toolbar shows "running" status)
- Confirm that the CAPL node has been correctly added to Simulation Setup
- Confirm that the node is enabled (node icon is not crossed out)
- Confirm that the focus is on the CANoe main window (not another application)
Issue 3: Can't Find Write Window
Solution:
- Click menu
View→Write - Or select
Writefrom theWindowdropdown menu in the toolbar
Issue 4: Special Characters Causing Compilation Failure
Use ordinary ASCII quotes and spaces in CAPL syntax. Character encoding and non-ASCII identifiers, strings or comments depend on the installed compiler and project settings; UTF-8 is not a universal repair. Reproduce the issue with the ASCII-only HelloWorld source, then consult that version's encoding documentation before adding localized text.
Summary
Through this article, we have accomplished:
- Understanding the basic structure and concepts of CANoe projects
- Familiarizing ourselves with CAPL Browser's interface layout (editor, navigator, output window, etc.)
- Hands-on creation of the first CAPL program: responding to key events and outputting text
- Learning the complete process of compiling programs, adding simulation nodes, and running measurements
- Mastering troubleshooting methods for several common issues
Exercises
-
Extended Exercise: Modify the program so that pressing the
bkey outputs "Goodbye, CANoe!" Hint: You'll need to add anotheron keyevent. -
Exploration Exercise: Try using the
writeEx()function instead ofwrite()and observe the different output. -
Challenge Exercise: Create a program that outputs "One" when pressing the
1key, "Two" when pressing the2key, and "Three" when pressing the3key.