CANoe Getting Started Series--Using CAPL to Realize Simple Switching Lights

CANoe Getting Started Series


1. Create a new project

Double-click to select CANFD500kBaud/4MBaud

Example: pandas is a NumPy-based tool created to solve data analysis tasks.
The new page is as follows
insert image description here

2. Create nodes through DBC

insert image description here
Select the storage location of dbc
insert image description here
Right-click Network nodes, create switch and light nodes
insert image description here
insert image description here
Create Message, fill in Name, the smaller the ID value, the higher the priority (light does not need too high priority, the allocation is three digits)
insert image description here
Create Signal, just DLC It is 1, 1byte=8bit, and the length range here is 1~8.
insert image description here
Drag Signals to Messages
insert image description here
and then drag messages to switch to save.
insert image description here
Right-click database, import Wizard, import the newly created dbc,
insert image description here
select the dbc just now, and The node moves to Assigned nodes
insert image description here

show as below
insert image description here

Build the canvas Panel

insert image description here

Add switch and LED legends to the canvas
insert image description here
Save Panel
insert image description here

Configure environment variables

Enter SystemVariables under Environment
insert image description here
to create a new NameSpace, and create switch and light environment variables
insert image description here
insert image description here
. Open the Panel again, set the environment variable to graphical, and save
insert image description here
insert image description here

Signal transmission using CAPL programming

Double-click the light node to create a new can file. After the switch receives the signal, the light sends a signal
insert image description here

on sysvar switch_light_namespace::sl_switch{
  //先获取到switch变化的msg信息
  message switch_light_msg switch_light_msg;
  //将变化后的信号值赋给signal
  switch_light_msg.switch_light_sig=@this;
  //返回msg信息
  output(switch_light_msg);
}

on message switch_light_msg{
  //让LED的信号值去等于开关变化后的值
  @switch_light_namespace::sl_light=this.switch_light_sig;
}

run

Select emulated bus
insert image description here
insert image description here

Guess you like

Origin blog.csdn.net/weixin_48143996/article/details/129499087