1

I'm new to CANoe and CAPL scripting. I need to update a byte of CAN message based on a change in another byte through a panel. I added a CAPL script for the automatic change/update but when I send/update the byte through the panel it sends the default values for the other bytes. It gets corrected in the next sample.

includes
{
  
}

variables
{  
    message M2P_0x101 msg1;
    msTimer timer10ms;
    byte counter = 1; 
}

on message M2P_0x101
{
    
    if(counterAlive == 15)
    {
        counterAlive = 0;
    }
    else
    {
        counter++;
    }
  
    msg1.byte(0) = this.byte(0);
    msg1.byte(1) = this.byte(1);
    msg1.byte(2) = this.byte(2);
    msg1.byte(3) = this.byte(3); // Changing through the Panel
    msg1.byte(4) = this.byte(3)+1;
    msg1.byte(5) = this.byte(5);
    msg1.byte(6) = counter; 
    msg1.byte(7) = this.byte(7);
}

on timer timer10ms
{
    output(msg1);
}

on start
{
    setTimerCyclic(timer10ms, 10);
}

4th & 6th byte has default value because 3rd byte was changed from the panel. I expected the 4th byte to be 1(value of 3rd byte + 1) and the 6th byte to be 4(counter value).

How to solve it? As far as I understand, it seems that the panel inputs/changes are sent to the CAN bus first and then CAPL node reads it and makes changes. This could be the reason for overwriting the other bytes of the message with default values.

Is there a way to include the changes made by CAPL before the panel sends the message to the CAN bus? A combination of Panel & CAPL node?

Keshav
  • 93
  • 1
  • 1
  • 10
  • 1
    A panel cannot *send* to the CAN bus. A panel has (CAPL) behind it which can put something on the bus. From your description that code should be the place where you should modify your message. Please show the code associated with your panel‘s actions. Apart from that, the `on message` block is invoked, when the message is seen on the bus. Based on your description, that might be too late. – MSpiller Aug 17 '22 at 08:36
  • Yes, you are right. I figured it out. I declared all info in sys var and assigned the inputs from panel to the msg1 in CAPL. If I change anything in panel it goes to to CAPL and adds the autogenerated Counter and sends it to CAN bus. This way, nothing resets. :) – Keshav Aug 17 '22 at 15:23

0 Answers0