Ejemplo n.º 1
0
  public static int calcCrcCCITT(byte b[], int bOfs, int bLen) {
    int W = 0xFFFF;
    if (b != null) {

      /* initialize CRC table */
      if (crc_CCITT_Table == null) {
        Checksum.initCrcCCITT();
      }

      /* adjust offset/length */
      int ofs = (bOfs <= 0) ? 0 : (bOfs >= b.length) ? b.length : bOfs;
      int len = ((bLen >= 0) && (bLen <= (b.length - ofs))) ? bLen : (b.length - ofs);

      /* calc CRC */
      for (int i = 0; i < len; i++) {
        W = (crc_CCITT_Table[(b[i + ofs] ^ (W >>> 8)) & 0xFF] ^ (W << 8)) & 0xFFFF;
      }
    }
    return W;
  }
Ejemplo n.º 2
0
 /* startup init */
 static {
   Checksum.initCrcCCITT();
 }