checksum Layer
Last updated
Was this helpful?
Last updated
Was this helpful?
The <checksum> layer represents checksum bytes, usually (but not always) present at the end of the .
The <checksum> layer has all the properties as well as extra properties and elements described below.
sum - Sum of all the bytes.
where polynomial is 0x1021
, initial value is 0xffff
, final XOR value is 0
, and no reflection of bytes.
where polynomial is 0x8005
, initial value is 0
, final XOR value is 0
, reflection is performed on every
byte as well as final value.
where polynomial is 0x04C11DB7
, initial value is 0xffffffff
, final XOR value is 0xffffffff
, reflection is
performed on every byte as well as final value.
custom - Custom algorithm, code for which needs to be provided to the
code generator, so it can copy it to the generated code.
When custom algorithm is selected, its name must be provided using algName property.
The provided name of the custom algorithm can be used by the code generator to locate the required external implementation file and use appropriate class / function name when the calculation functionality needs to be invoked.
The checksum layer definition must also specify the layers, data of which is used to calculate the checksum. It is done using from property that is expected to specify name of the layer where checksum calculation starts.
The example above defines SYNC | SIZE | ID | PAYLOAD | CHECKSUM
frame where the checksum is calculated on SIZE
+ ID
+ PAYLOAD
bytes.
Some protocols may put checksum value as prefix to the area on which the checksum needs to be calculated. In this case use until property (instead of from) to specify layers for checksum calculation.
The checksum calculation algorithm must be specified using alg . Supported values are:
crc-ccitt (aliases: crc_ccitt) -
crc-16 (aliases: crc_16) - ,
crc-32 (aliases: crc_32) - ,
The default behavior of the <checksum> layer is to perform calculation after all relevant layers and their fields have been successfully read and processed. However, it is possible to force the checksum verification right away (without reading fields of other layers and/or message payload). It is usually possible to do when value of the field is already processed, so the right location of checksum value is known, and it is not included in checksum calculation. To force immediate checksum verification use verifyBeforeRead with value.
Use for future references.