com.dalsemi.onewire.utils
Class CRC16

java.lang.Object
  |
  +--com.dalsemi.onewire.utils.CRC16

public class CRC16
extends Object

CRC16 is a class containing 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.


Method Summary
static int compute(byte[] dataToCrc)
          Perform the CRC16 on an array of data elements based on a zero seed.
static int compute(byte[] dataToCrc, int seed)
          Perform the CRC16 on an array of data elements based on the provided seed.
static int compute(byte[] dataToCrc, int off, int len)
          Perform the CRC16 on an array of data elements based on a zero seed.
static int compute(byte[] dataToCrc, int off, int len, int seed)
          Perform the CRC16 on an array of data elements based on the provided seed.
static int compute(int dataToCrc)
          Perform the CRC16 on the data element based on a zero seed.
static int compute(int dataToCrc, int seed)
          Perform the CRC16 on the data element based on the provided seed.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

compute

public static int compute(int dataToCrc)
Perform the CRC16 on the data element based on a zero seed.

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

Parameters:
dataToCrc - data element to perform crc16 on

compute

public static int compute(int dataToCrc,
                          int seed)
Perform the CRC16 on the data element based on the provided seed.

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

Parameters:
dataToCrc - data element to perform crc16 on

compute

public static int compute(byte[] dataToCrc)
Perform the CRC16 on an array of data elements based on a zero seed.

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

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

compute

public static int compute(byte[] dataToCrc,
                          int off,
                          int len)
Perform the CRC16 on an array of data elements based on a zero seed.

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

Parameters:
dataToCrc - array of data elements on which to perform crc16
off - offset into the data array
len - length of data to CRC16
Returns:
CRC16 value

compute

public static int compute(byte[] dataToCrc,
                          int off,
                          int len,
                          int seed)
Perform the CRC16 on an array of data elements based on the provided seed.

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

Parameters:
dataToCrc - array of data elements on which to perform crc16
off - offset into the data array
len - length of data to CRC16
seed - seed to use for CRC16
Returns:
CRC16 value

compute

public static int compute(byte[] dataToCrc,
                          int seed)
Perform the CRC16 on an array of data elements based on the provided seed.

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

Parameters:
dataToCrc - array of data elements on which to perform the crc8
seed - seed to use for crc16