git.ucc.asn.au
/
zanchey
/
dispense2.git
/ blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
history
|
raw
|
HEAD
Work on vending machine module
[zanchey/dispense2.git]
/
sql-edition
/
servers
/
CRC.py
1
crctab = []
2
CRC16 = 0x1021
3
4
def do_crc(message, crc = 0):
5
for i in range(0,len(message)):
6
crc = ((crc << 8) ^ (crctab[(crc >> 8) ^ ord(message[i])])) & 0xffff
7
return crc
8
9
# Generate crctab
10
for val in range(0,256):
11
crc = val << 8;
12
for i in range(0,8):
13
crc = crc << 1
14
if (crc & 0x10000):
15
crc = crc ^ CRC16
16
crctab.append(crc & 0xffff)
UCC
git Repository :: git.ucc.asn.au