What is the difference between system variable and environment variables in CAPL script with example?
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:
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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With