[英]CAPL: Why am I not receiving the data bytes of a CAN message in CAPL?
我有一个 ECU 发送带有 2 个字节数据的 CAN 消息。 我想在 CAPL 中获取这 2 个数据字节并将它们放入 2 个环境变量中。 我正在开发独木舟模拟,我想使用这 2 个环境变量在面板中显示它们的值。
我看到 CAN 消息中的数据字节被正确接收,但是当我尝试在 CAPL 中使用这些数据字节时,它们是 0。
我有以下代码:
message CAN1.SWversion SWversion;
on message SWversion
{
putValue(ev_MainSW, SWversion.MainSW);
putValue(ev_SecSW, SWversion.SecSW);
}
SWversion.MainSW 是字节(0),SWversion.SecSW 是字节(1)。 我在跟踪中看到它们的值,但在 CAPL 中它们是 0。
关于为什么的任何提示?
我想到了:
message CAN1.SWversion SWversion;
on message SWversion
{
putValue(ev_MainSW, SWversion.MainSW);
putValue(ev_SecSW, SWversion.SecSW);
}
需要改为
message CAN1.SWversion SWversion;
on message SWversion
{
putValue(ev_MainSW, this.byte(0));
putValue(ev_SecSW, this.byte(1);
}
显然,您不能使用预定义的信号来访问 CAPL 中 CAN 消息中的数据。
在您的事件处理程序中,您似乎应该访问接收到的消息,而不是全局(显然未初始化)变量:
on message CAN1.SWversion
{
putValue(ev_MainSW, this.MainSW);
putValue(ev_SecSW, this.SecSW);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.