Skip to content

Instantly share code, notes, and snippets.

View hiroyuki's full-sized avatar
🐘

hiroyuki hori - horristic hiroyuki

🐘
View GitHub Profile
@hiroyuki
hiroyuki / CRC
Created August 23, 2012 03:21
CRC16 encode/check
bool checkCrc()
{
u_short crc = BCapMessage::getMemCRC16( 0xffff, (u_char *)receivedData, 1, message_length - 3 );//add CRC by horristic
bool result = (receivedData[ message_length - 2 ] << 8) + receivedData[ message_length - 3 ] == crc;
return result;
}
static u_short getMemCRC16( unsigned short crc16, unsigned const char buff[], unsigned const short from, unsigned const short to )
{
int i;
unsigned short CRC16Table[ 256 ] = {