What is the difference between system variable and environment variables in CAPL script?

Sachin Bharambe picture Sachin Bharambe · Mar 18, 2016 · Viewed 24.5k times · Source

What is the difference between system variable and environment variables in CAPL script with example?

Answer

An Other picture An Other · Apr 19, 2016

Environment variables have to be used as input/output of a node, mostly they belongs to specified ECU. They are defined by following system-parameters:

  • access for specified ECU's (r, w, rw, unrestricted => each ECU can access)
  • datatype: int (32bit), string (ascii), float, data + data length
  • unit/dimension
  • initial value, min, max values
  • value tables can be defined (probably only for int datatype?)

You can directly access environment variables by using @:

@EnvLightState

but you can't do this only for int or float. Any datatype can be accessed by using this two simple functions:

CAPL Function Overview » General » getValue

CAPL Function Overview » General » putValue

System variables are widely used by CANoe components, many of them are generated automatically and can't be edited. They belongs to a defined namespace. The values of sysvars are available only while measurement is running, so you don't want to use them for e.g. UI-panels.

  • datatype: int (32, 64), double, string, data, array of int, array of double, pre-defined structs (user defined not allowed)
  • initial value can be defined
  • value tables can be defined for int datatype

you can "directly" access sysvar by using

 @Namespace1::ParameterArray[2];
 @Namespace1::Parameter2;

however, this ways it's not possible to access the whole array or string (data is not mentioned in help, but probably same thing). You also can't access any of sysvar defined in XML-Test module by using @, read about this in help:

Direct Access to Values from System Variables

There are CAPL-Functions defined for System variables (SysGet..., SysSet..., SysDefine..., SysUndefine... and some other) take look into help:

CAPL Function Overview » System Variables CAPL Functions

here an example from XML test function Set where both is used, you can find this example in CANoe help

<!-- Context of this test function is e.g. a testcase, other contexts are possible -->    
<set title="Set">
    <cansignal name="CrashDetected"> 0 </cansignal>
    <linsignal name="MotorControl"> 0 </linsignal>
    <flexraysignal name="BreakLight"> 0 </flexraysignal>
    <envvar name="EnvAccelerate"> 0 </envvar>
    <sysvar name="SysFrontLight_Right" namespace="Lights">0</sysvar>
</set>
<wait time="200" title="Swing in time for system" />

please extend if you know/find any other differences