updates
This commit is contained in:
parent
0822cb5503
commit
0293f6d5e6
10
golay.py
10
golay.py
@ -225,7 +225,7 @@ def decode_2087(_data):
|
||||
|
||||
def encode_2087(_data):
|
||||
value = data[0]
|
||||
cksum = ENCODING_TABLE_2087[value]
|
||||
cksum = ENCODE_2087[value]
|
||||
data[1] = cksum & 0xFF
|
||||
data[2] = cksum >> 8
|
||||
return _data
|
||||
@ -239,3 +239,11 @@ if __name__ == '__main__':
|
||||
|
||||
from binascii import b2a_hex as h
|
||||
from time import time
|
||||
|
||||
# For testing the code
|
||||
def print_hex(_list):
|
||||
print('[{}]'.format(', '.join(hex(x) for x in _list)))
|
||||
|
||||
data = [0x12,0x23,0x45]
|
||||
|
||||
print_hex(encode_2087(data))
|
6
qr.py
6
qr.py
@ -72,14 +72,14 @@ def get_synd_1576(_pattern):
|
||||
def encode(_data):
|
||||
value = (_data[0] >> 1) & 0x7F
|
||||
cksum = ENCODE_1676[value]
|
||||
data[0] = cksum >> 8
|
||||
data[1] = cksum & 0xFF
|
||||
_data[0] = cksum >> 8
|
||||
_data[1] = cksum & 0xFF
|
||||
return _data
|
||||
|
||||
def decode(_data):
|
||||
code = (_data[0] << 7) + (_data[1] >> 1)
|
||||
syndrome = get_synd_1576(code)
|
||||
error_pattern = DECODING_TABLE_1576[syndrome]
|
||||
error_pattern = DECODE_1576[syndrome]
|
||||
code ^= error_pattern
|
||||
return code >> 7
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user