com.ibutton.tmex.utils
Class CRC16

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

public class CRC16
extends java.lang.Object

iButtonCRC is a class to contain an implementation of the Cyclic-Redundency-Check (CRC) CRC16. The CRC16 is used in iButton memory packet structure.

CRC16 is based on the polynomial = X^16 + X^15 + X^2 + 1.


Constructor Summary
CRC16()
          Construct this object with both the crc8 and crc16 initial seeded to 0.
 
Method Summary
 int doCRC16(char dataToCrc)
          Perform the CRC16 on the data element based on the private crc16 value.
 int doCRC16(char[] dataToCrc)
          Perform the CRC16 on an array of data elements based on the private crc16 value.
 int getCRC16()
          Retrieve the current CRC16 value
 int getInvCRC16()
          Retrieve the inverted current CRC16 value.
 void seedCRC16(int crcSeed)
          Seed the crc16 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

CRC16

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

getCRC16

public int getCRC16()
Retrieve the current CRC16 value
Returns:
the current CRC16

seedCRC16

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

getInvCRC16

public int getInvCRC16()
Retrieve the inverted current CRC16 value.

The inverted CRC16 is used when writing to the memory iButtons for short condition reasons.

Returns:
the bitwise inverted CRC16 of the length and data

doCRC16

public int doCRC16(char dataToCrc)
Perform the CRC16 on the data element based on the private crc16 value.

CRC16 is based on the polynomial = X^16 + X^15 + X^2 + 1.

Parameters:
dataToCrc - data element to perform crc16 on

doCRC16

public int doCRC16(char[] dataToCrc)
Perform the CRC16 on an array of data elements based on the private crc16 value.

CRC16 is based on the polynomial = X^16 + X^15 + X^2 + 1.

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