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

30,005

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

Share:
30,005
Sachin Bharambe
Author by

Sachin Bharambe

A result-oriented software professional with 5+ years of experience as manual and automation test engineer, worked on various automotive features like Instrument Cluster, in vehicle infotainment, Rear Seat Entertainment, Vehicle Interface and Speech domain.

Updated on December 22, 2020

Comments

  • Sachin Bharambe
    Sachin Bharambe over 3 years

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