-1

I am trying to send a message continuously after a key stroke and also reset the message after a set time.

includes
{

}

variables
{
  int i;
  int j;
}

On key 'a'
{
  j = 1;

}

on start
{
  if(j == 1 && i <= 300)
  {
    message MyMessage msg;
    msg.signal1 = 1;
    msg.signal2 = 600;
    output(msg);
    i++;
  }
  if(i>300)
  {
    message MyMessage msg;
    msg.signal1 = 0;
    msg.signal2 = 0;
    output(msg);
    j = 0;
  }
}

So, on the key press 'A', it needs to keep sending the message for 3 sec, but after 3 sec is over. it needs to reset my message to 0.

I thought that "on start" is called every cyclic period. But it looks like I am wrong.

Aashu10
  • 49
  • 10

1 Answers1

0

On start will be called only once after clicking the yellow flash symbol in CANoe. You can use a timer that can be called periodically for every 10/whatever ms you want. In On timer function you can have logic for your requirement.

You can use the below CAPL script as reference and modify it as per your requirement.

includes
{
}

variables
{  int i;
  int j;
  mstimer timer1;
}

On key 'a'
{
  j = 1;

}

On timer timer1
{
  if(j >= 1 && i <= 300)
  {
    message MyMessage msg;
    msg.signal1 = 1;
    msg.signal2 = 600;
    output(msg);
    i++;
  }
  if(i>300)
  {
    message MyMessage msg;
    msg.signal1 = 0;
    msg.signal2 = 0;
    output(msg);
    j = 0;
  }
  settimer(timer1,10);
}

on start
{
    j = 0;
    i = 0;
    settimer(timer1,10);
}