I have this byte array:
static byte[] buf = new byte[] { (byte) 0x01, (byte) 0x04, (byte)0x00, (byte)0x01,(byte)0x00, (byte) 0x01};
Now the CRC checksum of this byte array should be 0x60, 0x0A. I want the Java code to recreate this checksum, however I cannot recreate it. I tried crc16:
static int crc16(final byte[] buffer) { int crc = 0xFFFF; for (int j = 0; j < buffer.length ; j++) { crc = ((crc >>> 8) | (crc << 8) )& 0xffff; crc ^= (buffer[j] & 0xff);
and convert them using Integer.toHexString (), but none of the results match the correct CRC. Can someone please point me in the right direction in terms of the CRC formula.
java crc checksum modbus
Greengodot
source share