I have a CAPL file attached to a CAN node that periodically sends a message using the 'output' function. How can I use a second CAPL file to block the node sending the message (while doing everything that the node does) ?
Asked
Active
Viewed 5,966 times
3 Answers
1
You can stop all your cyclic messages, by canceling timers of Each message
Example:
message can1.0x12 message1;
msTimer tmessage1;
on timer tmessage1
{
output(message1); // sending message
setTimer(tmessage1,100); // set the cyclic time as 100ms
}
on envVar envmessage1
{
if (getValue(envmessage1) == 1)
{
setTimer(tmessage1,100); // set and start the cyclic time as 100ms
}
else
{
cancelTimer(tmessage1); // cancel the cyclic timer
}
}
if you just do envmessage1 = 0
in another node, it will stop the message, like the same for all messages, have to write environment variable, then you can control other Node messages.

Om Choudhary
- 492
- 1
- 7
- 27

Kapildevreddy
- 11
- 1
1
You can create a sysvar in your simulation, which will be used as a switch in your simulated *.can
Network node.
You just have to condition the output code to the value of the system variable you created.
if (Sysvar_SimEnabled)
{
output(message);
output(message1);
output(message3);
}
This Sysvar_SimEnabled
will be a global variable, thus can be set to any value from another *.can
CAPL Network node.

Om Choudhary
- 492
- 1
- 7
- 27

VioletVynil
- 502
- 5
- 11