How to pass length in CRC16 modbus calculation in java?
I have found the following method in the link:
http://www.codeproject.com/Articles/19214/CRC-16-Calculation
How to pass length value in the second argument.
public int crc16(byte[] modbusframe,int Length)
{
int i;
int index;
int crc_Low = 0xFF;
int crc_High = 0xFF;
for (i = 0; i<Length; i++ )
{
index = crc_High ^ (char)modbusframe[i];
crc_High = crc_Low ^ crc_table[index];
crc_Low = (byte)crc_table[index+ 256];
}
return crc_High*256+crc_Low;
}
Thanks in advance..