Hallo,
ich habe eine Klasse mit der ich CRC16 berechne, Weiß jemand wie man testen kann ob die Berechnung richtig ist bzw. gibts irgendwo Vergleichswerte (Eingabe, Ausgabe)?
ich habe eine Klasse mit der ich CRC16 berechne, Weiß jemand wie man testen kann ob die Berechnung richtig ist bzw. gibts irgendwo Vergleichswerte (Eingabe, Ausgabe)?
Code:
public class CRCBerechnung
{
private int crc = 0;
private byte[] testBytes;
public CRCBerechnung()
{
}
public int calcCRC(byte[] value)
{
short crc = (short) 0xFFFF;
for (int j = 0; j < value.length; j++)
{
byte c = value[j];
for (int i = 0; i < 8; i++)
{
boolean c15 = ((crc >> 15 & 1) == 1);
boolean bit = ((c >> (7 - i) & 1) == 1);
crc <<= 1;
if (c15 ^ bit)
crc ^= 0xa001; // 0x1021;
}
}
System.out.println("CRC16 = " + Integer.toHexString(crc));
return crc;
}
}