EasyManua.ls Logo

ONOFFSYSTEM NEOS-HSD200 - CRC-16 (Modbus) Algorithm

ONOFFSYSTEM NEOS-HSD200
54 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...
ONOFFSYSTEM Co., Ltd.
Heat and Smoke detector NEOS-HSD200 User Manual
- 40 -
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;
}