Home > other >  C to Java
C to Java

Time:01-03

#include
Unsigned char crc_low_first (unsigned char * PTR, unsigned char len)//multibyte check the low byte first
{
unsigned char i;
Unsigned char CRC=0 x00; The original CRC value of computation/* */
While (len -)//check for computation of the received data values
{
CRC ^=* ptr++;//* every time and the need to compute the data of different or first, calculating the data point to the next *

For (I=0; i <8; I++)
{
If ((CRC & amp; 0 x01)!=0)
CRC=(CRC & gt; & gt; 1) ^ 0 x8c;
The else CRC=CRC & gt; & gt; 1;
}
}

The return of CRC;
}

Int main ()
{

Unsigned char a [15]={0 x60, 0 x07, 0 x00 to 0 x00 to 0 x00 to 0 x02, 0 x83, 0 x00 to 0 x00 to 0 x00 to 0 x04, 0 xd0, 0 x07, 0 x00 to 0 x00};

Printf (" % x, "crc_low_first (a, 15));//multibyte check low byte first);
return 0;
}
  • Related