ECU Measurement and Calibration Toolkit C API Reference

Content Type
Programming Language
Current manual

mcCalculateChecksum

mcCalculateChecksum

Purpose

Calculates the checksum of a data block in memory.

Format

mcTypeStatus mcCalculateChecksum(
mcTypeTaskRef ECURefNum,
u32 BlockSize,
u8 *Data,
u8 TypeOfChecksum,
u8 *SizeOfChecksum,
u32 *Checksum);

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:

TypeNameDescription
0x01XCP_ADD_11Add BYTE into a BYTE checksum, ignore overflows
0x02XCP_ADD_12Add BYTE into a WORD checksum, ignore overflows
0x03XCP_ADD_14Add BYTE into a DWORD checksum, ignore overflows
0x04XCP_ADD_22Add WORD into a WORD checksum, ignore overflows, blocksize must be modulo 2
0x05XCP_ADD_24Add WORD into a DWORD checksum, ignore overflows, blocksize must be modulo 2
0x06XCP_ADD_44Add DWORD into DWORD, ignore overflows, blocksize must be modulo 4
0x07XCP_CRC_16Refer to CRC error detection algorithms
0x08XCP_CRC_16_CITTRefer to CRC error detection algorithms
0x09XCP_CRC_32Refer to CRC error detection algorithms
0xFFXCP_USER_DEFINEDUser 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

Was this information helpful?