4 typedef unsigned char byte;
5 typedef unsigned int uint;
8 u16 crc_update(u16 crc, byte data)
10 crc = crc ^ (data << 8);
11 for (uint i=0; i<8; i++) {
13 crc = (crc << 1) ^ 0x1021;
24 0x00, // length (will be filled)
26 0x3d, 0x2e, 0x11, 0x25,
31 msg[3] = sizeof(msg) + 2;
34 for (uint i=0; i < sizeof(msg); i++) {
35 printf("%02x ", msg[i]);
36 crc = crc_update(crc, msg[i]);
38 printf("%02x %02x\n", crc >> 8, crc & 0xff);