def crc16(data_blk):
data_blk_size = len(data_blk)<EOL>crc_accum = <NUM_LIT:0><EOL>for j in range(data_blk_size):<EOL><INDENT>i = ((crc_accum >> <NUM_LIT:8>) ^ data_blk[j]) & <NUM_LIT><EOL>crc_accum = ((crc_accum << <NUM_LIT:8>) ^ crc_table[i])<EOL>crc_accum &= <NUM_LIT>  <EOL><DEDENT>return crc_accum<EOL>
Calculate crc

in: data_blk - entire packet except last 2 crc bytes
out: crc_accum - 16 word