Module CrcMoose :: Class CrcAlgorithm
[frames] | no frames]

Class CrcAlgorithm

source code

Represents the parameters of a CRC algorithm.

Instance Methods
 
__init__(self, width, polynomial, name=None, seed=0, lsbFirst=False, lsbFirstData=None, xorMask=0) source code
 
__repr__(self) source code
 
calcString(self, s, value=None)
Calculate the CRC of the 8-bit string s.
source code
 
calcWord(self, word, width, value=None)
Calculate the CRC of the integer word as a sequence of width bits.
source code
 
reflect(self)
Return the algorithm with the bit-order reversed.
source code
 
reverse(self)
Return the algorithm with the reverse polynomial.
source code
Method Details

__init__(self, width, polynomial, name=None, seed=0, lsbFirst=False, lsbFirstData=None, xorMask=0)
(Constructor)

source code 
Parameters:
  • width (an integer) - The number of bits in the CRC register, or equivalently, the degree of the polynomial.
  • polynomial (sequence or integer) - The generator polynomial as a sequence of exponents
  • name (str) - A name identifying algorithm.
  • seed (an integer) - The initial value to load into the register. (This is the value without xorMask applied.)
  • lsbFirst (bool) - If true, the register shifts toward the least-significant bit (sometimes called the reflected or reversed algorithim). Otherwise, the register shifts toward the most-significant bit.
  • lsbFirstData (bool) - If true, input data is taken least-significant bit first. Otherwise, data is taken most-significant bit first. If None or not given, the value of lsbFirst is used.
  • xorMask (an integer) - An integer mask indicating which bits should be inverted when returning the final result. This is also used for the input value if provided.