Professional Documents
Culture Documents
SN-IMC-1-036 Cyclic Redundancy Check
SN-IMC-1-036 Cyclic Redundancy Check
2020-07-01
Support Note SN-IMC-1-036
Table of Contents
1 Description ....................................................................................................................................... 2
2 Disclaimer ........................................................................................................................................ 2
3 Requirements................................................................................................................................... 2
4 Source Code .................................................................................................................................... 2
4.1 Calc_CRC ................................................................................................................................ 2
4.2 Check_CRC ............................................................................................................................. 3
4.3 Output-Function ....................................................................................................................... 4
5 Handling ........................................................................................................................................... 4
5.1 Theory ...................................................................................................................................... 4
5.1.1 Figures ........................................................................................................................... 5
6 Contacts ........................................................................................................................................... 5
Cyclic Redundancy Check (CRC8 Calculation)
1 Description
Computation of an 8-bit binary CRC for error detection to accidental changes to raw data. For every
measurement point in the measurement file a check value, based on the remainder of a polynomial
division is computed and returned by the function. The hits will be generated when an error occurred!
2 Disclaimer
Permission is hereby granted, free of charge, to any person obtaining a copy of this function and/or
script and associated documentation files (the "Software"), to deal in the Software without restriction,
including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial
portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
3 Requirements
Be sure the generator polynomial used in both functions doesn't differ. Access to raw data only with
the .BLF format.
4 Source Code
4.1 Calc_CRC
/*---------------------------------------------------------------------------
| Name: Calc_CRC
|
| Description: Computation of an 8-bit binary CRC for Error Detection to
| accidental changes to raw data.
| For every measurement point in the measurement file a check
| value, based on the remainder of a polynomial division is
| computed and returned by the function.
| Hits will be generated when an error occurred!
|
| Arguments: ----
|
| Glob. Variables: ----
| Functions: The return-value is used as an input of the function "checkCRC",
| which computes the checksum
|
| Attention: Be sure the generator polynomial used in both functions, doesn't
| differ. Access to raw data only with the .blf format.
|
| Execution: Data Mining
|
| Developed by: Vector / Steve Himmel
| --------------------------------------------------------------------------*/
function calcCRC (byte0)//, byte1, byte2, byte3, byte5, byte6, byte7)
{
#define CRCMASK 0xd5; //generator polynomial
unsigned char reg; //shift register
unsigned char data=0;
int i;
data=byte0;
4.2 Check_CRC
/*---------------------------------------------------------------------------
| Name: Check_CRC
|
| Description: Computation of an 8-bit binary CRC for Error Detection to
| accidental changes to raw data.
| For every measurement point in the measurement file a check
| value, based on the remainder of a polynomial division is
| computed and returned by the function.
| Hits will be generated when an error occurred!
|
| Arguments: Result from calcCRC
|
| Glob. Variables: ----
| Functions: calcCRC
|
| Attention: Be sure the generator polynomial used in both functions, doesn't
| differ.
| Access to raw data only with the .blf format.
|
| Execution: Data Mining
|
| Developed by: Vector / Steve Himmel
--------------------------------------------------------------------------*/
data = byte0;
reg = byte0 ^ CRCMASK;
for(i=0;i<7;++i)
{
data <<= 1;
if(reg&0x80)
{
reg ^= CRCMASK;
}
reg <<= 1;
4.3 Output-Function
/*---------------------------------------------------------------------------
| Name: test
|
| Description: Output, Handling for generated hits
|
| Arguments: ----
|
| Glob. Variables: ----
| Functions: The return-value is used as an input of the function "checkCRC",
| which computes the checksum
|
| Attention: Be sure the generator polynomial used in both functions, doesn't
| differ.
| Access to raw data only with the .blf format.
|
| Execution: Data Mining
|
| Developed by: Vector / Steve Himmel
|
--------------------------------------------------------------------------*/
5 Handling
5.1 Theory
A generator polynomial with r digits leads to r-1 = n digits to fill up in the frame.
5.1.1 Figures
6 Contacts
For support related questions please address to the support contact for your country
https://www.vector.com/int/en/company/contacts/support-contact/.