Search code examples
can-buscaplcanoe

CAPL: Why am I not receiving the data bytes of a CAN message in CAPL?


I have an ECU sending a CAN message with 2 bytes of data. I want to take those 2 data bytes in CAPL and put them into 2 environment variables. I am developing a canoe simulation and I want to use those 2 environment variables to display their value in a panel.

I am seeing the CAN message with the data bytes on trace being received correctly, but when I try using those data bytes in CAPL, they are 0.

I have the following code:

message CAN1.SWversion  SWversion;

on message SWversion
{
  putValue(ev_MainSW, SWversion.MainSW);
  putValue(ev_SecSW, SWversion.SecSW);
}

SWversion.MainSW is byte(0), SWversion.SecSW is byte(1). I see their values on trace, but in CAPL they are 0.

Any hints as to why?

Here's my trace window with the data bytes

Here's my message & signals definition in the database

Here's one of my variable definitions


Solution

  • I figured it out:

    message CAN1.SWversion  SWversion;
    
    on message SWversion
    {
      putValue(ev_MainSW, SWversion.MainSW);
      putValue(ev_SecSW, SWversion.SecSW);
    }
    

    needed to be changed to

    message CAN1.SWversion  SWversion;
    
    on message SWversion
    {
      putValue(ev_MainSW, this.byte(0));
      putValue(ev_SecSW, this.byte(1);
    }
    

    Apparently, you cannot use predefined signals to access the data in a CAN message in CAPL.