简体   繁体   English

CAN消息信号,CAPL

[英]CAN message signals, CAPL

I am trying to save the signal data in the each my of a CAN message in separate variables. 我试图将信号数据保存在CAN消息的每个my变量中。 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); 我在CANalyzer的CAPL中有一个dlc = 4的CAN消息'msg1',信号为{8,5,7,21},我想将它们保存在变量中,例如:int var1 = msg1.byte(0); but I keep getting zero (0) as the final value of the variable after the operation. 但在操作之后,我始终获得零(0)作为变量的最终值。

Any help is much appreciated. 任何帮助深表感谢。 Thanks 谢谢

If you are not doing this already, implement an on message event using the keyword this: 如果尚未执行此操作,请使用关键字this实现一个on message事件:

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

The event will always be triggered when CANalyzer receives the message specified in the on message event. 当CANalyzer收到on message事件中指定的消息时,将始终触发该事件。 This way you can also make sure that the value stored by var1 is up to date. 这样,您还可以确保var1存储的值是最新的。 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);
  }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM