This function, given a data buffer (sequence of bytes), performs the CRC16 calculation based on the specified polynomial and initial CRC value.
Syntax |
u16 crc16_le (string strData, i32 nCount [, u16 initVal=0xFFFF] [, u16 polin=0xA001]) |
||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
strData |
String or array of which CRC16 is to be calculated. However, the CRC calculation is done on bytes, regardless of the type specified for the given variable |
||||||||||||||||||||||||||||||||
nCount |
This is the number of bytes of strData on which to perform the calculation |
||||||||||||||||||||||||||||||||
initVal |
Initial value of CRC. (optional, default 0xFFFF) |
||||||||||||||||||||||||||||||||
polin |
Value of the polynomial used in CRC calculation. (optional, default 0xA001) Main polynomials used by different CRCs:
Frequent cases:
|
||||||||||||||||||||||||||||||||
Result |
Returns the calculated CRC value |
||||||||||||||||||||||||||||||||
Validity |
Rule, Task |
||||||||||||||||||||||||||||||||
Note |
By repeatedly calling the function with initial value equal to the calculated CRC value, one can perform incremental calculation of the CRC of a buffer of any length. NOTE: The previous crc16_ero function (Little Endian with unmodifiable initial polynomial 0xA001) is deprecated, but remains for compatibility. |
The calculation is done according to the Little Endian algorithm.
Example of use:
|