I have a CANoe environment where I am simulating a series of nodes and their associated frames using a DBC file. Some of these frames have 8-bit CRC checksums for the payloads, which I am calculating successfully in CAPL using Crc_CalculateCRC8.
The problem arises when I manually change the value of a signal (be it through a panel, vTESTstudio script, etc...). Because I am using the "on signal" event handler to recalculate the CRC, it only triggers after the signal has already been updated on the bus. This means the first frame after a signal has been updated comes up with a CRC checksum fault which is subsequently fixed on receipt of the next frame. Is there a way for me to access the value of a signal before it is sent on the bus (like the value stored in the Interaction Layer stack/buffer)?
I know I could get around this by creating separate system variables and modifying these in the panels/scripts, but that would defeat the purpose, as I would then lose access to the signal value tables and add a lot of extra complexity.
I'm sure there must be a simple way to do this using inbuilt CANoe functionality, as CRC's are such a common feature...
Thanks
If you are using a dbc, you can simply use the capl function applILTxPending() for this. It enables you to change the data before IL sends data to the bus. (note: I have not compiled this, hopefully works without errors)
dword applILTxPending(long aId, dword aDlc, byte data[])
{
// if the message 0x060 contains the crc data in 0th byte
byte crc;
int i;
if (aID == 0x60)
{
// crc calculation (or use Crc_CalculateCRC8() as you need here)
crc = 0xFF;
for (i=1;i<cDlc,++i)
{
crc = crc ^ data[i];
}
// set the crc
data[0] = crc;
}
return 1; // this keeps sending the message
}