EasyManua.ls Logo

Grow GM66 - 8. Serial Port Instructions and Zone Bits; 8.1 CRC Algorithm

Grow GM66
60 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
31
8 Serial Port Instruction
Users can settle the module by sending instruction from mainframe.
Please make sure communicate parameter complete matching between module and mainframe.
Module default serial communicate parameter: Baud rate 9600bps; No check; 8 bit data; 1 bit stop
bit; No flow control.
8.1CRC Algorithm
CRC: CRC_CCITT check value (2 bytes).
Suitable for TypesLensAddressDatas;
Characteristic polynomial : X16+X12+X5+1, multinomial coefficient: 0x1021, original value:0 ;
For single byte, the highest bit will be calculated at first, output will be without negation.
Reference code of C:
unsigned int crc_cal_by_bit(unsigned char* ptr, unsigned int len)
{
unsigned int crc = 0;
while(len-- != 0)
{
for(unsigned char i = 0x80; i != 0; i /= 2)
{
crc *= 2;
if((crc&0x10000) !=0)
crc ^= 0x11021;
if((*ptr&i) != 0)
crc ^= 0x1021;
}
ptr++;
}
return crc;
}
PS: when no need for checking CRC, CRC bite can be filled in 0xAB 0xCD

Related product manuals