Created
April 17, 2016 05:46
-
-
Save oilking143/9e9b21bf32c097f79f7f4be1af381da3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private int Calculate_CRC16(byte[] buff, int len) | |
{ | |
int u16CRC; | |
u16CRC = 0xFFFF; | |
for(int i=0; i<len; i++) | |
{ | |
u16CRC = ((u16CRC>>8) | (u16CRC<<8))&0xFFFF; | |
u16CRC ^= (buff[i]&0xFF); | |
u16CRC ^= ((u16CRC&0xFF)>>4); | |
u16CRC ^= (u16CRC<<12)&0xFFFF; | |
u16CRC ^= ((u16CRC&0xFF)<<5)&0xFFFF; | |
} | |
u16CRC &= 0xFFFF; | |
return u16CRC; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment