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

Class CrcRegister

source code

Holds the intermediate state of the CRC algorithm.

Instance Methods
 
__init__(self, crcAlgorithm, value=None) source code
 
__str__(self) source code
 
reset(self)
Reset the state of the register with the default seed value.
source code
 
takeBit(self, bit)
Process a single input bit.
source code
 
takeWord(self, word, width=8)
Process a binary input word.
source code
 
takeString(self, s)
Process a string as input.
source code
 
getValue(self)
Return the current value of the register as an integer.
source code
 
getFinalValue(self)
Return the current value of the register as an integer with xorMask applied.
source code
Method Details

__init__(self, crcAlgorithm, value=None)
(Constructor)

source code 
Parameters:
  • crcAlgorithm (CrcAlgorithm) - The CRC algorithm to use.
  • value (an integer) - The initial register value to use. The result previous of a previous CRC calculation, can be used here to continue calculation with more data. If this parameter is None or not given, the register will be initialized with algorithm's default seed value.

takeWord(self, word, width=8)

source code 
Process a binary input word.
Parameters:
  • word (an integer) - The input word. Since this can be a Python long, there is no coded limit to the number of bits the word can represent.
  • width (an integer) - The number of bits word represents.

takeString(self, s)

source code 
Process a string as input. It is handled as a sequence of 8-bit integers.

getFinalValue(self)

source code 
Return the current value of the register as an integer with xorMask applied. This can be used after all input data is processed to obtain the final result.