Canoe8

4.8.2   Creating an Empty Function For Node BBB


In order for CANoe to be able to simulate the network, every node must have a program associated with it. We will make an empty program for Node BBB.

1)   In the Simulation Setup window of CANoe, click on the pencil icon located on the lower left corner of the
“BBB” network node to open the CAPL Browser.

2)   An Open dialog window will appear asking for the CAPL program to be given a name. Type in
“BBB.can” and save the file in the “new1” directory. Then, click on Open.

3)   Select Compiler Compile

4)   On the upper menu, go to File Save to save the empty CAPL program. Then, close the CAPL Browser.


Now, let's test what we have done so far.

1)   In the main CANoe application, make sure the panels are open.

2)   Make sure the Trace Window can be seen (menu command Window Trace). Click on the [Start]
button (the "lightning bolt" icon) on the CANoe toolbar.

3)   On the “aaa” Panel window, right- or left-click on the rocker switch ("aaaSwitch_1A").

4)   A message with a new time stamp is displayed in the Trace Window every time the switch is clicked, which indicates that the CAN message, aaaMsg, is being transmitted onto the CAN bus.

5)   To stop the simulation, click on the [Stop] button (the “stop sign” icon) on the CANoe toolbar. The simulation must be in the stopped state before any changes to the setup can be made.


Next, let's move the switch press information into the message.

1)   Using the menu, go to Window Simulation Setup. Click the pencil icon of node “AAA” to edit the
CAPL program.

2)   Expand "Environment" in the tree view at the left and select "aaaSwitch_1A".

3)   In the lower right window, where the code is, change the program source code to read as follows:

on envVar aaaSwitch_1A
{
aMsg.switch_1A = getValue(this);
output(aMsg);
}
4)   On the toolbar, click the "Compile" icon (a single arrow pointing down onto a stack of papers) or select Compiler Compile. (If a compile error is shown, then double click on the listed error line to get to the line in the program causing the problem.)

5)   On the bottom window, make sure the last line says “Compiled …”. If not compiled successfully, make sure the code is entered exactly as shown in Steps 3 and 7.


6)   On the upper menu, go to File Save to save the CAPL program. Then, close the CAPL Browser. Our compiled and finished program should now look like this in the CAPL Browser:

Now, let's check the result.
1)   In the main CANoe application, make sure the Trace Window can be seen. Click on the [Start] button
(the “lightning bolt” icon).

2)   In the “aaa” Panel window, right- or left-click on the rocker switch ("aaaSwitch_1").

3)   The time stamp of the message can be seen in the Trace Window, followed by columns for the channel, ID, message name. The next two columns are Dir TX (Direction: transmit) and DLC (Data Length Code), which is 2 bytes of data. The last column shows the actual data.

4)   Click on the plus sign (+) to the left to expand the message and see its signals on the next three rows.

5)   Click the switch on the panel several times. The "switch_1" signal will change from "On" to "Off" and
"On" again, and the time stamp can also be seen each time when this is done. The Trace Window should now look like this:
4.8.3   Programming Node BBB Behavior


We will now read the message transmitted by the AAA node and move the switch press of Node AAA into the indicator on Node BBB.

1)   In CANoe, go to Window Simulation Setup.

2)   In the Simulation Setup window of CANoe, click on the pencil icon located on the lower left corner of the
“BBB” network node to open the CAPL Browser.

3)   In the Global Variables section (upper right) enter the following:

variables {

message bbbMsg bMsg;

}

4)   Right click on "CAN Messages" in the tree view at the left and select New.

5)   In the code window at the lower right, replace the string "<newMessage>" with "aaaMsg" so it reads "on message aaaMsg" (meaning "on receiving  message "aaaMsg" we will do the following:")

6)   Enter the following code:

on message aaaMsg
{
putValue (bbbIndicator_B, this.switch_1A);
bMsg.Indicator_B = this.switch_1A;
output (bMsg);
}

7)   On the toolbar, click the "Compile" icon (a single arrow pointing down onto a stack of papers) or select Compiler Compile. (If a compile error is shown, then double-click on the listed error line to get to the line in the program causing the problem.)

8)   On the bottom window, make sure the last line says “Compiled …”. If not compiled successfully, make sure the code is entered exactly as shown in Steps 3 and 7.

9)   On the upper menu, go to File Save to save the CAPL program. Then, close the CAPL Browser.
Let's check the behavior of both network nodes. In CANoe, run the simulation again. This time, the Trace window will display two messages – each transmitted by a node.


5.0  Conclusion


We now have a working model of a network with two nodes. Continue to work on this network if desired by adding new behavior, such as:

•    Use bbbSwitch_1A of the bbb panel to toggle the indicator on the aaa panel.

•    Experiment with other types of controls in the Panel Editor (radio buttons, track bars, edit fields, etc.)

•    Add and disable nodes in the Simulation Setup window.
Using the example demo files that have been included with CANoe also helps the user learn more about
CANoe.



6.0  Overview of Interrelated CANoe Files


CANoe uses a collection of interrelated files for each user configuration.

For each CANoe configuration there is a single Configuration File typically associated with a single Database File. For each user-defined node a Program File is used, and for every panel there is a Panel File, as can be seen in Table 1.

CANoe File Type
Suffix
Text Format
Number of Files
Configuration File
.cfg
Yes
1
Database File
.dbc
Yes
Typically 1
Program File (CAPL)
.can
Yes
1 for each user-defined node
Panel File
.xvp
Yes
1 for each user-defined panel

Table 1 – Primary CANoe File Types





No comments:

Post a Comment