示例#1
0
文件: crc16.c 项目: LongJeongS/csc209
unsigned short crc_message(unsigned int key,  unsigned char *message, int num_bytes) {
	unsigned short reg = 0;
	int i;

	for (i = 0; i < num_bytes; i++ )
		crc_byte(&reg, key, message[i]);

	// push all databytes through the register
	for (i = 0; i < 2; i++) {
		crc_byte(&reg, key, 0);
	}
	return reg;
}
示例#2
0
static uint16_t crc_packet(uint8_t *data, int len)
{
  uint16_t crc = 0;

  while (len-- > 0)
    crc = crc_byte(crc, *data++);

  return crc;
}
示例#3
0
static void escape_byte(serial_source src, uint8_t b)
{
  src->send.crc = crc_byte(src->send.crc, b);
  if (b == SYNC_BYTE || b == ESCAPE_BYTE)
    {
      escape_add(src, ESCAPE_BYTE);
      escape_add(src, b ^ 0x20);
    }
  else
    escape_add(src, b);
}