参考文献:

1、CANoe帮助文档:

CAPL Functions » CANoe IL » applILTxPending

Example

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. 
  /* Message 0x1A1 contains a 4-Bit message counter in the first 4 Bits of Byte 7.
  /* It will be calculated from the other data bytes of the message.
  */
  
  if(aId == 0x1A0)
  {
    // calculate checksum
    xor = 0x00;
    for(i = 1; i < aDlc; ++i) {
      xor = xor ^ data[i];
    }
    // set the new checksum
    data[0] = xor;

    // get the old counter value
    i = (data[7] & 0xF0) >> 4;
    data[7] &= 0x0F;
    // increment
    i++;
    i = i % 16;
    //set the new message counter
    data[7] |= (i << 4) & 0xF0;
  }
  return 1; // don't prevent sending of the message
}

 

相关文章:

  • 2021-06-28
  • 2021-09-08
  • 2021-12-15
  • 2021-06-11
  • 2021-04-07
  • 2021-07-08
  • 2021-07-14
  • 2021-09-15
猜你喜欢
  • 2021-04-06
  • 2021-09-15
  • 2021-08-24
  • 2022-12-23
  • 2021-05-17
  • 2021-07-29
相关资源
相似解决方案