1

I'm just learning to use CAPL on CANoe and I need to create a gateway that filters messages between 2 CAN Buses.

For the first part I need to create a way to toggle the transmission from Bus 1 to Bus 2 and vice versa (already done).

Then I have to be able to select a specific message from any of the buses to send it over to the other bus. All of this must be don graphically with a panel and I'm using checkboxes for the toggle of part 1 and dropdown lists for the message filter.

Do you know of a way to get a list of the active (Rx/Tx) messages in a bus from the last, say, 10 seconds? (I know I must use a timer to call the update function)

scott_lotus
  • 3,171
  • 22
  • 51
  • 69
mrLucius
  • 33
  • 1
  • 12

1 Answers1

1

You can subscribe to all messages from a bus by defining an on message event handler. It will be called for each message (subject to the filter condition you have specified). You can create a gateway by retransmitting messages using output.

For example, your graphical panel can set a variable my_id to the ID of a message you want to relay from bus 1 to bus 2. You could then write:

on message CAN1.*
{
   message CAN2.* msg;
   if((this.dir == rx) && (this.id == my_id)) {
       msg = this;
       output(msg);
   }
}

The additional condition this.dir == rx is necessary if you want to relay the same message from bus 1 to bus 2 and vice versa. It will prevent you from retransmitting the same message indefinitely.

Dmitry Grigoryev
  • 3,156
  • 1
  • 25
  • 53