M.A
M.A

Reputation: 23

How to set env variable in CAPL code from an incoming signal?

I use CANoe and i want to add node that take Signals and change env variables

using CAPL coding of course for example:

on signal Signal_Name
{
   set env variable = SET;
}

Upvotes: 1

Views: 12719

Answers (2)

Daemon Painter
Daemon Painter

Reputation: 3470

There is no on signal * procedure in CAPL, due to the fact that signals are always transferred as packets of a message. So, you will end up using something like this:

on signal ( LightSwitch::OnOff | MotorSwitch::OnOff )
{
  putValue (yourEnvironmentVariable, this);      // Maybe phys, if applies
}

Note that a on envVar yourEnvironmentVariable/* is triggered immediately after this call. Finally, the on envVar * event is always fired when accessing the environment variable, meaning that it does not care if the actual value assigned to the variable has changed or not.

According to the References, and thanks to @M.Spiller, the procedure is called as soon as one of the signals changes.

Upvotes: 0

Joe Joseph
Joe Joseph

Reputation: 87

You can use,

@Env_Variable_Name = 1;

For example, I have an environment variable named Env_DrvDrSw

on key 'a'
{
    @Env_DrvDrSw = 1; 
}

But CAPL has a small limitation, since the CAPL is an event based programming, The on envVar Env_DrvDrSw part in your CAPL code will be executed after the execution of on key 'a' event. You cannot expect it to work like C language.

Hopefully I clarified your question. Correct me if I'm wrong.

Upvotes: 2

Related Questions