can-buscaplcanalyzer

CAN message signals, CAPL


I am trying to save the signal data in the each my of a CAN message in separate variables. For eg. I have a CAN message 'msg1' of dlc =4, with signals {8, 5, 7, 21} in CANalyzer's CAPL, I would like to save them in variables like: int var1 = msg1.byte(0); but I keep getting zero (0) as the final value of the variable after the operation.

Any help is much appreciated. Thanks


Solution

  • If you are not doing this already, implement an on message event using the keyword this:

    on message msg1 {
      var1 = this.byte(0);
      ...
    }
    

    The event will always be triggered when CANalyzer receives the message specified in the on message event. This way you can also make sure that the value stored by var1 is up to date. You can also use a more general approach using arrays.

    on message msg1 {
      int i;
      int var[msg1.dlc];
      for (i = 0; i < msg1.dlc; i++) {
        var[i] = this.byte(i);
      }
    }