0

I am new in CANoe, and also CAPL language. I would like to know how to send a message periodically ( 100ms) on CAN 1 (incrementing a byte in the payload with every sending, i.e. message counter), receive this message on CAN2 and when it is received automatically a response should be transmitted, that has the received message counter as one byte in the payload.

bobby
  • 2,629
  • 5
  • 30
  • 56
Ran
  • 1
  • 1
  • 1
  • 1

1 Answers1

1

In CANoe, please hit F1 to enter the guide, then browse to chapter CAPL Functions and give it a read through. This will help you understand the following principles.

In order to send a message periodically, you want to declare a message variable type in the variables block of your script and a timer. The CAN association is usually done in the *.dbc file, but you may even configure the CAN bus in the CAPL script.

variables {
    message 0xA m1;
            // 0xA is the message ID from your *.dbc can database used in the simulation
    timer timer100;
}

You want to set the timer, for instance on simulation start, and then output your message inside the timer callback like this:

on start {
    timer100.set(100);
}

on timer timer100 {
    // reset timer
    timer100.set(100);
    // do stuff to your message content
    // for instance m1.signalA = 0x01;
    // ...
    output(m1)  // send m1 on CAN bus
}

You also want to do stuff whenever a message is read, then do something like

on message m2 {
     // ...
}

You might want to try it out on your own first, and then perhaps update your question to be more precise. Right now, it feels like you don't have really put any effort into this.

Daemon Painter
  • 3,208
  • 3
  • 29
  • 44