com.ibutton.tmex.utils
Class iButtonCRC

java.lang.Object
  |
  +--com.ibutton.tmex.utils.iButtonCRC

public class iButtonCRC
extends java.lang.Object

iButtonCRC is a class to contain an implementation of the Cyclic-Redundency-Check CRC8 for the iButton. The CRC8 is used in the iButton ID number of all iButtons.

CRC8 is based on the polynomial = X^8 + X^5 + X^4 + 1.


Constructor Summary
iButtonCRC()
          Construct this object with both the crc8 and crc16 initial seeded to 0.
 
Method Summary
 int doCRC(int dataToCRC)
          Perform the CRC8 on the data element based on the private crc8 value.
 int doCRC(int[] dataToCrc)
          Perform the CRC8 on an array of data elements based on the private crc8 value.
 int getCRC()
          Retrieve the current CRC8 value
 void seedCRC(int crcSeed)
          Seed the crc8 by setting it to the provided value
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

iButtonCRC

public iButtonCRC()
Construct this object with both the crc8 and crc16 initial seeded to 0.
Method Detail

getCRC

public int getCRC()
Retrieve the current CRC8 value
Returns:
the current CRC8

seedCRC

public void seedCRC(int crcSeed)
Seed the crc8 by setting it to the provided value
Parameters:
crcSeed - crc8 value to set

doCRC

public int doCRC(int dataToCRC)
Perform the CRC8 on the data element based on the private crc8 value.

CRC8 is based on the polynomial = X^8 + X^5 + X^4 + 1.

Parameters:
dataToCrc - data element to perform crc8 on

doCRC

public int doCRC(int[] dataToCrc)
Perform the CRC8 on an array of data elements based on the private crc8 value.

CRC8 is based on the polynomial = X^8 + X^5 + X^4 + 1.

Parameters:
dataToCrc - array of data elements to perform crc8 on