【CAPL】applILTxPending()函数: CAN报文发送前的字节预处理
applILTxPending函数
1.applILTxPending函数定义
- 在IL(Interaction Layer,交互层)向总线发送消息之前,可以选择调用此回调。
- 在此回调中,可以阻止消息的发送或更改消息的数据。
2.applILTxPending函数作用:
- 对指定CANID的报文进行字节的预处理;
- 可以对每一帧报文的特定字节做数据操作处理;
- (applILTxPending函数通常用于计算滚动的Checksum和Counter上,对字节的处理非常方便)。
3.applILTxPending与output(msg) 相比较的优势是什么?
- applILTxPending不用定义多条报文及其他报文参数,
- 更适合周期发送数据库的报文,可以自由选择需要发送的报文,周期、发送类型;
4.applILTxPending与IG节点 相比较的优势是什么?
- applILTxPending可以动态更改字节的内容,IG节点不行,且无法做逻辑处理;
- 1)applILTxPending函数的作用:对指定CANID的报文进行字节的预处理;
- 2)applILTxPending函数的说明:可以对每一帧报文的特定字节做数据操作处理;
(applILTxPending函数通常用于计算滚动的Checksum和Counter上,对字节的处理非常方便) - 3)applILTxPending函数的参数解析:
文档定义
-
语法
-
代码示例
//Calculation of a checksum and a message counter: dword applILTxPending (long aId, dword aDlc, byte data[]) { dword i; byte xor; /* Message 0x1A0 contains a XOR checksum in Byte 0. It will /* be calculated from the other data bytes of the message. */ if(aId == 0x1A0) { // calculate xor = 0x00; for(i = 1; i < aDlc; ++i) { xor = xor ^ data[i]; } // set the new checksum data[0] = xor; } /* Message 0x1A1 contains a 4-Bit message counter in /* the first 4 Bits of Byte 0. */ if(aId == 0x1A1) { // get the old value i = data[0] & 0x0F; // increment i++; i = i % 16; //set the new message counter data[0] = i & 0x0F; } return 1; // don't prevent sending of the message }
CANoe相关操作
参考链接
-
在本视频教程中用到此函数:
-
其他博文参考: