private int calculateCRC(ByteBuffer buf){
  buf.get();
  int c=0xFFFF;
  for (int i=0; i < definition.payloadLength + HEADER_LENGTH - 1; i++) {
    c=MAVLinkCRC.accumulateCRC(buf.get(),c);
  }
  c=MAVLinkCRC.accumulateCRC(definition.extraCRC,c);
  return c;
}

private int calculateCRC ( ByteBuffer buf ) { buf . get ( ) ; int c = 0xFFFF ; for ( int i = 0 ; i < definition . payloadLength + HEADER_LENGTH - 1 ; i ++ ) { c = MAVLinkCRC . accumulateCRC ( buf . get ( ) , c ) ; } c = MAVLinkCRC . accumulateCRC ( definition . extraCRC , c ) ; return c ; }
calculate crc of the message , buffer position should be set to start of the message .
