crc.detector
(Removed) Construct CRC detector object
crc.detector has been removed. To detect errors in input data using cyclic redundancy check
(CRC), use the comm.CRCDetector
System object instead. For more
details on the recommended workflow, see Version History.
Syntax
h= crc.detector(polynomial)
h= crc.detector(generatorObj)
h= crc.detector(‘Polynomial’, polynomial, ‘param1’, val1,
etc.)
h= crc.detector
Description
h= crc.detector(polynomial)
constructs a CRC detector object H defined
by the generator polynomial POLYNOMIAL
h= crc.detector(generatorObj)
constructs a CRC detector object H
defined by the parameters found in the CRC generator object GENERATOROBJ
h= crc.detector('property1', val1, ...)
constructs a CRC detector
object H with properties as specified by PROPERTY/VALUE pairs.
h= crc.detector
constructs a CRC detector object H with default
properties. It constructs a CRC-CCITT detector, and is equivalent to:
h=
crc.detector('Polynomial','0x1021','InitialState','0xFFFF','ReflectInput',false,'ReflectRemainder',false,'FinalXOR','0x0000')
Properties
The following table describes the properties of a CRC detector object. All properties
are writable, except Type
.
Property | Description |
---|---|
Type | Specifies the object as a 'CRC Detector'. |
Polynomial | The generator polynomial that defines connections for a linear feedback shift register. This property can be specified as a binary vector representing descending powers of the polynomial. In this case, the leading '1' of the polynomial must be included. It can also be specified as a string, prefaced by '0x', that is a hexadecimal representation of the descending powers of the polynomial. In this case, the leading '1' of the polynomial is omitted. |
InitialState | The initial contents of the shift register. This property can be specified as a binary scalar, a binary vector, or as a string, prefaced by '0x', that is a hexadecimal representation of the binary vector. As a binary vector, its length must be one less than the length of the binary vector representation of the Polynomial. |
ReflectInput | A Boolean quantity that specifies whether the input data should be flipped on a bytewise basis prior to entering the shift register. |
ReflectRemainder | A Boolean quantity that specifies whether the binary output CRC checksum should be flipped around its center after the input data is completely through the shift register. |
FinalXOR | The value with which the CRC checksum is to be XORed just prior to detecting the input data. This property can be specified as a binary scalar, a binary vector or as a string, prefaced by '0x', that is a hexadecimal representation of the binary vector. As a binary vector, its length must be one less than the length of the binary vector representation of the Polynomial. |
A detect method is used with the object to detect errors in digital transmission.
CRC Generation Algorithm
For information pertaining to the CRC generation algorithm, see Cyclic Redundancy Check Codes.
Detector Method
[OUTDATA ERROR] = DETECT(H, INDATA)
detects transmission errors in the
encoded input message INDATA
by regenerating a CRC checksum using the CRC
detector object H. The detector then compares the regenerated checksum with the checksum
appended to INDATA. The binary-valued INDATA can be either a column vector or a matrix. If
it is a matrix, each column is considered to be a separate channel. OUTDATA is identical to
the input message INDATA, except that it has the CRC checksum stripped off. ERROR is a 1xC
logical vector indicating if the encoded message INDATA has errors, where C is the number of
channels in INDATA. An ERROR value of 0 indicates no errors, and a value of 1 indicates
errors.
Examples
Create a CRC-16 CRC generator, then use it to generate a checksum for the binary vector represented by the ASCII sequence '123456789'. Introduce an error, then detect it using a CRC-16 CRC detector.
gen = crc.generator('Polynomial', '0x8005', 'ReflectInput', ... true, 'ReflectRemainder', true); det = crc.detector('Polynomial', '0x8005', 'ReflectInput', ... true, 'ReflectRemainder', true); % The message below is an ASCII representation % of the digits 1-9 msg = int2bit((49:57)',8); encoded = generate(gen, msg); encoded(1) = ~encoded(1); % Introduce an error [outdata error] = detect(det, encoded); % Detect the error noErrors = isequal(msg, outdata) % Should be 0 error % Should be 1
This example generates the following output:
noErrors = 0 error = 1