mcCalculateChecksum
- Updated2023-02-21
- 2 minute(s) read
mcCalculateChecksum
Purpose
Calculates the checksum of a data block in memory.
Format
mcTypeStatus | mcCalculateChecksum(
|
Input
ECURefNum
ECURefNum is the task reference which links to the selected ECU. This reference is originally returned from mcECUSelectEx.
BlockSize
BlockSize determines the size of the block on which the checksum has to be calculated.
Output
TypeOfChecksum
TypeOfChecksum specifies the type of the calculated checksum.
Data
Data is a byte array over which the checksum calculation is performed.
SizeofChecksum
SizeofChecksum returns the size in bytes of the calculated checksum.
Checksum
Checksum is the calculated checksum.
Return Value
The return value indicates the status of the function call as a signed 32-bit integer. Zero means the function executed successfully. A negative value specifies an error, which means the function did not perform the expected behavior. A positive value specifies a warning, which means the function performed as expected, but a condition arose that may require attention.
Use the mcStatusToString function of the ECU M&C API to obtain a descriptive string for the return value.
Description
mcCalculateChecksum implements a checksum calculation over a given data block. The checksum algorithm is performed over a dedicated checksum function provided by a specific DLL. The name of the Checksum DLL is defined in the A2L data base and can be changed by the application by the mcSetProperty function using the mcPropECU_Checksum property.
If you are using the CCP protocol, TypeOfChecksum must be set to 0xFFh, since CCP only supports an external checksum DLL. If you are using XCP, the following values for TypeOfChecksum are defined in the XCP specification:
Type | Name | Description |
---|---|---|
0x01 | XCP_ADD_11 | Add BYTE into a BYTE checksum, ignore overflows |
0x02 | XCP_ADD_12 | Add BYTE into a WORD checksum, ignore overflows |
0x03 | XCP_ADD_14 | Add BYTE into a DWORD checksum, ignore overflows |
0x04 | XCP_ADD_22 | Add WORD into a WORD checksum, ignore overflows, blocksize must be modulo 2 |
0x05 | XCP_ADD_24 | Add WORD into a DWORD checksum, ignore overflows, blocksize must be modulo 2 |
0x06 | XCP_ADD_44 | Add DWORD into DWORD, ignore overflows, blocksize must be modulo 4 |
0x07 | XCP_CRC_16 | Refer to CRC error detection algorithms |
0x08 | XCP_CRC_16_CITT | Refer to CRC error detection algorithms |
0x09 | XCP_CRC_32 | Refer to CRC error detection algorithms |
0xFF | XCP_USER_DEFINED | User defined algorithm, in externally calculated function |
For a detailed description of the checksum algorithm refer to the mcBuildChecksum command or the XCP Part 2 Protocol Layer Specification.
For more detailed information about CRC algorithms, please refer to:
http://www.repairfaq.org/filipg/LINK/F_crc_v34.html