ONOFFSYSTEM Co., Ltd.
Heat and Smoke detector NEOS-HSD200 User Manual
5.2.7. CRC-16(Modbus) Algorithm
1) Create CRC
uint16_t CRC16(uint8_t* buf, size_t len)
{
Uint16_t crc = 0xffff;
for(int pos = 0; pos < len; pos++)
{
crc ^= (uint16_t)buf[pos];
for(int i = 8; I !=0; i--)
{
if((crc & 0x0001) != 0)
{
crc >>=1;
crc ^= 0xA001;
}
else
{
}
}
}
crc >>=1;
return crc;
}