Navigation Menu

Skip to content

Commit

Permalink
Fixed the initial value of the 16-bit CCITT algorithm.
Browse files Browse the repository at this point in the history
Renamed the model from ccitt to crc-16-ccitt.
Fixes #7. Thanks to Craig McQueen.
  • Loading branch information
tpircher-zz committed Oct 25, 2015
1 parent 0fdd4ef commit 78d3056
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 8 deletions.
8 changes: 8 additions & 0 deletions ChangeLog
@@ -1,3 +1,11 @@
2015-10-25 Thomas Pircher <tehpeh-pycrc@tty1.net>

* crc_models.py:
* doc/pycrc.xml:
Fixed the initial value of the 16-bit CCITT algorithm. Renamed the model
from ccitt to crc-16-ccitt.
Fixes #7. Thanks to Craig McQueen.

2015-10-11 Thomas Pircher <tehpeh-pycrc@tty1.net>

* doc/pycrc.xml:
Expand Down
6 changes: 3 additions & 3 deletions crc_algorithms.py
Expand Up @@ -40,9 +40,9 @@
>>> crc = Crc(width = 16, poly = 0x8005,
... reflect_in = True, xor_in = 0x0000,
... reflect_out = True, xor_out = 0x0000)
>>> print("0x{0:x}".format(crc.bit_by_bit("123456789")))
>>> print("0x{0:x}".format(crc.bit_by_bit_fast("123456789")))
>>> print("0x{0:x}".format(crc.table_driven("123456789")))
>>> print("{0:#x}".format(crc.bit_by_bit("123456789")))
>>> print("{0:#x}".format(crc.bit_by_bit_fast("123456789")))
>>> print("{0:#x}".format(crc.table_driven("123456789")))
"""

# Class Crc
Expand Down
6 changes: 3 additions & 3 deletions crc_models.py
Expand Up @@ -147,14 +147,14 @@ class CrcModels(object):
'check': 0xd64e,
})
models.append({
'name': 'ccitt',
'name': 'crc-16-ccitt',
'width': 16,
'poly': 0x1021,
'reflect_in': False,
'xor_in': 0xffff,
'xor_in': 0x1d0f,
'reflect_out': False,
'xor_out': 0x0,
'check': 0x29b1,
'check': 0xe5cc,
})
models.append({
'name': 'r-crc-16',
Expand Down
2 changes: 1 addition & 1 deletion crc_symtable.py
Expand Up @@ -1246,7 +1246,7 @@ def __pretty_hex(self, value, width=None):
if width == None:
return "{0:#x}".format(value)
width = (width + 3) // 4
hex_str = "0x{{0:0{0:d}x}}".format(width)
hex_str = "{{0:#0{0:d}x}}".format(width + 2)
return hex_str.format(value)


Expand Down
2 changes: 1 addition & 1 deletion doc/pycrc.xml
Expand Up @@ -223,7 +223,7 @@
<replaceable>crc-16-usb</replaceable>,
<replaceable>crc-16-modbus</replaceable>,
<replaceable>crc-16-genibus</replaceable>,
<replaceable>ccitt</replaceable>,
<replaceable>crc-16-ccitt</replaceable>,
<replaceable>r-crc-16</replaceable>,
<replaceable>kermit</replaceable>,
<replaceable>x-25</replaceable>,
Expand Down

0 comments on commit 78d3056

Please sign in to comment.