Use vCDL to Call Functions Between Programs

CANoe Quick Tip

Know How
Automotive
CANoe
Testing, Validation & Diagnostics

In CANoe, you often need to communicate between several of your simulation or test programs internally. You can use the vCDL description language to define interfaces for that purpose, enabling a powerful and versatile function call mechanism.

What Can You Do With It? | What Problems Does It Solve?

Your CANoe configuration usually contains several, or even many programs: tests, application models, simulated nodes, etc. While these programs are nominally independent, you must still often use some internal communication between them:

  • Your test needs to switch a model into a different internal mode.
  • You have a model that mocks specific functionality, and your test must tell it which data it should provide.
  • Your model is programmed mainly in CAPL, but to do some work in a background task, an auxiliary application model written in C# is used.
  • Your model is programmed mainly in Python, but to access lower-level bus functionality, an auxiliary application model written in CAPL is used. 
  • Your test wants to use the IL fault injection feature and must tell the CAPL program at the simulated node to call the corresponding function.

You may already have solved some of these cases by using one or more System Variables for internal communication. The vCDL description language provides a much more powerful mechanism: you can declare functions there which you can then implement in one program and call from another program.

Where Can You Find This Function in CANoe? | How to Start the Process?

First, create a vCDL file as a “new data source” in the Communication Setup of CANoe. In the file, add an object with an internal method member, for example:

namespace Example {
  object TestHelpers {
    internal method int32 SwitchModelMode(uint16 newMode);
  }
}

You can use all data types which vCDL provides for the parameters, including strings, enums, lists, structs, …

Implement the method in one program with a function call handler, which is possible in CAPL, C# and Python. Here’s how it would look in CAPL:

on fct_call Example::TestHelpers.SwitchModelMode {
  Write("New model mode: %d", this.newMode);
  // ...
  this.Result = 0;
}

Call the method from another program, which again is possible in all programming languages. Here’s how it would look in C#:

var result = Example.TestHelpers.SwitchModelMode.Call(1);

You can also call the method asynchronously (using “CallAsync” instead of “Call”) and later wait for the return or use another event handler for the return.

You can even show the function calls and their returns in the Trace window.

Related CANoe Topics

Graphic of the CANoe cube.
More About CANoe
Looking for the Right Training?
VectorAcademy
Team
Looking for the Right Training?
We’re happy to help. If you have any questions about our training and certification programs or would like individual advice, simply use our contact form.