-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* crc_models.py: changed the xor-in value of the crc-64-jones model. * crc_models.py: Set xmodem parameters equal to the zmodem params. 2009-12-29 * pycrc.py, crc_opt.py, crc_parser: uniform error messages. * crc_opt.py: added a warning for even polynoms. 2009-11-12 * crc_models.py: added crc-16-modbus. Closes issue 2896611. 2009-11-07 * crc_opt.py: Fix for unused variable argv. Closes issue 2893224. Thanks to Marko von Oppen.
- Loading branch information
1 parent
ff903b0
commit 616d1f7
Showing
12 changed files
with
119 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
Copyright (c) 2006-2009, Thomas Pircher <[email protected]> | ||
Copyright (c) 2006-2010, Thomas Pircher <[email protected]> | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,30 @@ | ||
# | ||
# Version 0.7.4, 2010-01-24 | ||
# | ||
|
||
2010-01-24 Thomas Pircher <[email protected]> | ||
|
||
* crc_models.py: changed the xor-in value of the crc-64-jones model. | ||
* crc_models.py: Set xmodem parameters equal to the zmodem params. | ||
|
||
2009-12-29 Thomas Pircher <[email protected]> | ||
|
||
* pycrc.py, crc_opt.py, crc_parser: uniform error messages. | ||
* crc_opt.py: added a warning for even polynoms. | ||
|
||
2009-11-12 Thomas Pircher <[email protected]> | ||
|
||
* crc_models.py: added crc-16-modbus. Closes issue 2896611. | ||
|
||
2009-11-07 Thomas Pircher <[email protected]> | ||
|
||
* crc_opt.py: Fix for unused variable argv. | ||
Closes issue 2893224. Thanks to Marko von Oppen. | ||
|
||
# | ||
# Version 0.7.3, 2009-10-25 | ||
# | ||
|
||
2009-10-25 Thomas Pircher <[email protected]> | ||
|
||
* crc_models.py: renamed crc-32mpeg to crc-32-mpeg. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,15 +10,21 @@ Installation | |
pycrc requires Python 2.4 or later. Python 3.x is supported. | ||
|
||
This program doesn't need any particular installation. You may execute the | ||
script from any directory. On UNIX-oid platforms, you might need to make the | ||
script executable: chmod +x pycrc.py | ||
script from any directory. | ||
Simply call the python interpreter with the script : | ||
|
||
python pycrc.py [options] | ||
|
||
On UNIX-like systems, you might want to make the script executable: | ||
|
||
chmod +x pycrc.py | ||
|
||
|
||
Getting help | ||
============ | ||
|
||
If you have questions about using pycrc which is not answered satisfactorily by | ||
the documentation, please send a mail to the pycrc user mailing list | ||
If you have questions about using pycrc which is not answered in a satisfactory | ||
way by the documentation, please send a mail to the pycrc user mailing list | ||
<[email protected]>. The list info page is available at | ||
https://lists.sourceforge.net/lists/listinfo/pycrc-users | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
|
||
# pycrc -- parametrisable CRC calculation utility and C source code generator | ||
# | ||
# Copyright (c) 2006-2009 Thomas Pircher <[email protected]> | ||
# Copyright (c) 2006-2010 Thomas Pircher <[email protected]> | ||
# | ||
# Permission is hereby granted, free of charge, to any person obtaining a copy | ||
# of this software and associated documentation files (the "Software"), to deal | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
|
||
# pycrc -- parametrisable CRC calculation utility and C source code generator | ||
# | ||
# Copyright (c) 2006-2009 Thomas Pircher <[email protected]> | ||
# Copyright (c) 2006-2010 Thomas Pircher <[email protected]> | ||
# | ||
# Permission is hereby granted, free of charge, to any person obtaining a copy | ||
# of this software and associated documentation files (the "Software"), to deal | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
|
||
# pycrc -- parametrisable CRC calculation utility and C source code generator | ||
# | ||
# Copyright (c) 2006-2009 Thomas Pircher <[email protected]> | ||
# Copyright (c) 2006-2010 Thomas Pircher <[email protected]> | ||
# | ||
# Permission is hereby granted, free of charge, to any person obtaining a copy | ||
# of this software and associated documentation files (the "Software",, to deal | ||
|
@@ -124,6 +124,17 @@ class CrcModels(object): | |
'direct': True, | ||
'check': 0xb4c8, | ||
}) | ||
models.append({ | ||
'name': 'crc-16-modbus', | ||
'width': 16, | ||
'poly': 0x8005, | ||
'reflect_in': True, | ||
'xor_in': 0xffff, | ||
'reflect_out': True, | ||
'xor_out': 0x0, | ||
'direct': True, | ||
'check': 0x4b37, | ||
}) | ||
models.append({ | ||
'name': 'ccitt', | ||
'width': 16, | ||
|
@@ -171,13 +182,13 @@ class CrcModels(object): | |
models.append({ | ||
'name': 'xmodem', | ||
'width': 16, | ||
'poly': 0x8408, | ||
'reflect_in': True, | ||
'poly': 0x1021, | ||
'reflect_in': False, | ||
'xor_in': 0x0, | ||
'reflect_out': True, | ||
'reflect_out': False, | ||
'xor_out': 0x0, | ||
'direct': True, | ||
'check': 0xc73, | ||
'check': 0x31c3, | ||
}) | ||
models.append({ | ||
'name': 'zmodem', | ||
|
@@ -283,7 +294,7 @@ class CrcModels(object): | |
'width': 64, | ||
'poly': 0xad93d23594c935a9, | ||
'reflect_in': True, | ||
'xor_in': 0x0, | ||
'xor_in': 0xffffffffffffffff, | ||
'reflect_out': True, | ||
'xor_out': 0x0, | ||
'direct': True, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
|
||
# pycrc -- parametrisable CRC calculation utility and C source code generator | ||
# | ||
# Copyright (c) 2006-2009 Thomas Pircher <[email protected]> | ||
# Copyright (c) 2006-2010 Thomas Pircher <[email protected]> | ||
# | ||
# Permission is hereby granted, free of charge, to any person obtaining a copy | ||
# of this software and associated documentation files (the "Software"), to deal | ||
|
@@ -30,7 +30,7 @@ | |
from crc_opt import Options | ||
opt = Options() | ||
opt.parse(sys.argv) | ||
opt.parse(sys.argv[1:]) | ||
This file is part of pycrc. | ||
""" | ||
|
@@ -53,7 +53,7 @@ class Options(object): | |
Program details | ||
""" | ||
ProgramName = "pycrc" | ||
Version = "0.7.3" | ||
Version = "0.7.4" | ||
VersionStr = "%s v%s" % (ProgramName, Version) | ||
WebAddress = "http://www.tty1.net/pycrc/" | ||
|
||
|
@@ -174,7 +174,7 @@ def parse(self, argv = None): | |
action="store", type="string", dest="output_file", | ||
help="write the generated code to file instead to stdout", metavar="FILE") | ||
|
||
(options, args) = parser.parse_args() | ||
(options, args) = parser.parse_args(argv) | ||
|
||
undefined_params = [] | ||
if options.width != None: | ||
|
@@ -209,12 +209,15 @@ def parse(self, argv = None): | |
self.TableIdxWidth = options.table_idx_width | ||
self.TableWidth = 1 << options.table_idx_width | ||
else: | ||
sys.stderr.write("Error: unsupported table-idx-width %d\n" % options.table_idx_width) | ||
sys.stderr.write("%s: error: unsupported table-idx-width %d\n" % (sys.argv[0], options.table_idx_width)) | ||
sys.exit(1) | ||
|
||
if self.Poly != None and self.Poly % 2 == 0: | ||
sys.stderr.write("%s: warning: the polynom 0x%x is even. A valid CRC polynom must be odd.\n" % (sys.argv[0], self.Poly)) | ||
|
||
if self.Width != None: | ||
if self.Width <= 0: | ||
sys.stderr.write("Error: Width must be strictly positive\n") | ||
sys.stderr.write("%s: error: Width must be strictly positive\n" % sys.argv[0]) | ||
sys.exit(1) | ||
self.MSB_Mask = 0x1 << (self.Width - 1) | ||
self.Mask = ((self.MSB_Mask - 1) << 1) | 1 | ||
|
@@ -250,17 +253,17 @@ def parse(self, argv = None): | |
if alg == "table-driven" or alg == "all": | ||
self.Algorithm |= self.Algo_Table_Driven | ||
if self.Algorithm == 0: | ||
sys.stderr.write("Error: unknown algorithm %s\n" % options.algorithm) | ||
sys.stderr.write("%s: error: unknown algorithm %s\n" % (sys.argv[0], options.algorithm)) | ||
sys.exit(1) | ||
if self.Width != None and (self.Width % 8) != 0: | ||
if options.algorithm == "table-driven": | ||
sys.stderr.write("Error: width parameter is not aligned to byte boundaries; algorithm %s not applicable\n" % options.algorithm) | ||
sys.stderr.write("%s: error: width parameter is not aligned to byte boundaries; algorithm %s not applicable\n" % (sys.argv[0], options.algorithm)) | ||
sys.exit(1) | ||
else: | ||
self.Algorithm &= ~self.Algo_Table_Driven | ||
if self.Width != None and self.Width < 8: | ||
if options.algorithm == "table-driven": | ||
sys.stderr.write("Error: width < 8, algorithm %s not applicable\n" % options.algorithm) | ||
sys.stderr.write("%s: error: width < 8, algorithm %s not applicable\n" % (sys.argv[0], options.algorithm)) | ||
sys.exit(1) | ||
else: | ||
self.Algorithm &= ~(self.Algo_Table_Driven) | ||
|
@@ -272,7 +275,7 @@ def parse(self, argv = None): | |
elif std == "C99": | ||
self.CStd = std | ||
else: | ||
sys.stderr.write("Error: unknown C standard %s\n" % options.c_std) | ||
sys.stderr.write("%s: error: unknown C standard %s\n" % (sys.argv[0], options.c_std)) | ||
sys.exit(1) | ||
if options.symbol_prefix != None: | ||
self.SymbolPrefix = options.symbol_prefix | ||
|
@@ -298,30 +301,30 @@ def parse(self, argv = None): | |
if options.generate != None: | ||
arg = options.generate.lower() | ||
if arg != 'c' and arg != 'h' and arg != "c-main" and arg != "table": | ||
sys.stderr.write("Error: unknown operation %s\n" % options.generate) | ||
sys.stderr.write("%s: error: don't know how to generate %s\n" % (sys.argv[0], options.generate)) | ||
sys.exit(1) | ||
self.Action = "generate_" + arg | ||
op_count += 1 | ||
if self.Action == "generate_table": | ||
if self.Algorithm & self.Algo_Table_Driven == 0: | ||
sys.stderr.write("Error: the --generate table option is incompatible with the --algorithm option\n") | ||
sys.stderr.write("%s: error: the --generate table option is incompatible with the --algorithm option\n" % sys.argv[0]) | ||
sys.exit(1) | ||
self.Algorithm = self.Algo_Table_Driven | ||
elif self.Algorithm != self.Algo_Bit_by_Bit and self.Algorithm != self.Algo_Bit_by_Bit_Fast and self.Algorithm != self.Algo_Table_Driven: | ||
sys.stderr.write("Error: select an algorithm to be used in the generated file\n") | ||
sys.stderr.write("%s: error: select an algorithm to be used in the generated file\n" % sys.argv[0]) | ||
sys.exit(1) | ||
if op_count == 0: | ||
self.Action = "check_string" | ||
if op_count > 1: | ||
sys.stderr.write("Error: too many actions scecified\n") | ||
sys.stderr.write("%s: error: too many actions scecified\n" % sys.argv[0]) | ||
sys.exit(1) | ||
|
||
if len(args) != 0: | ||
sys.stderr.write("Error: unrecognized argument(s): %s\n" % " ".join(args)) | ||
sys.stderr.write("%s: error: unrecognized argument(s): %s\n" % (sys.argv[0], " ".join(args))) | ||
sys.exit(1) | ||
|
||
if self.UndefinedCrcParameters and (self.Action == "check_string" or self.Action == "check_hexstring" or self.Action == "check_file" or self.Action == "generate_table"): | ||
sys.stderr.write("Error: undefined parameters: Add %s or use --model\n" % ", ".join(undefined_params)) | ||
sys.stderr.write("%s: error: undefined parameters: Add %s or use --model\n" % (sys.argv[0], ", ".join(undefined_params))) | ||
sys.exit(1) | ||
self.Verbose = options.verbose | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
|
||
# pycrc -- parametrisable CRC calculation utility and C source code generator | ||
# | ||
# Copyright (c) 2006-2009 Thomas Pircher <[email protected]> | ||
# Copyright (c) 2006-2010 Thomas Pircher <[email protected]> | ||
# | ||
# Permission is hereby granted, free of charge, to any person obtaining a copy | ||
# of this software and associated documentation files (the "Software"), to deal | ||
|
@@ -132,7 +132,7 @@ def __parse_data(self): | |
elif tok == self.lex.tok_block_end: | ||
return True | ||
else: | ||
sys.stderr.write("Error: wrong token %s\n" % self.lex.text) | ||
sys.stderr.write("%s: error: wrong token %s\n" % (sys.argv[0], self.lex.text)) | ||
return False | ||
tok = self.lex.peek() | ||
return True | ||
|
@@ -168,13 +168,13 @@ def __parse_control(self, str): | |
self.if_stack.pop(0) | ||
return True | ||
elif self.lex.text == "else" or self.lex.text.startswith("elif "): | ||
sys.stderr.write("unmatched %s clause\n" % self.lex.text[:4]) | ||
sys.stderr.write("%s: error: unmatched %s clause\n" % (sys.argv[0], self.lex.text[:4])) | ||
return False | ||
else: | ||
if not self.__parse_literal(self.lex.text): | ||
return False | ||
return True | ||
sys.stderr.write("unknown token in control\n") | ||
sys.stderr.write("%s: %error: unknown token in control\n" % sys.argv[0]) | ||
return False | ||
|
||
# __parse_if | ||
|
@@ -187,7 +187,7 @@ def __parse_if(self, str): | |
try: | ||
condition = self.__parse_expression(exp) | ||
except ParseError: | ||
sys.stderr.write("parsing expression %s failed\n" % str) | ||
sys.stderr.write("%s: %error: parsing expression %s failed\n" % (sys.argv[0], str)) | ||
return False | ||
|
||
stack_state = self.if_stack[0] | ||
|
@@ -214,7 +214,7 @@ def __parse_elif(self, str): | |
try: | ||
condition = self.__parse_expression(exp) | ||
except ParseError: | ||
sys.stderr.write("parsing expression %s failed\n" % str) | ||
sys.stderr.write("%s: error: parsing of expression %s failed\n" % (sys.argv[0], str)) | ||
return False | ||
|
||
if condition: | ||
|
@@ -251,7 +251,7 @@ def __parse_block_start(self): | |
""" | ||
tok = self.lex.peek() | ||
if tok != self.lex.tok_block_start: | ||
sys.stderr.write("begin block expected, at %s\n" % self.lex.text) | ||
sys.stderr.write("%s: error: begin block expected, at %s\n" % (sys.argv[0], self.lex.text)) | ||
return False | ||
self.lex.advance(skip_nl = True) | ||
return True | ||
|
@@ -264,7 +264,7 @@ def __parse_block_end(self): | |
""" | ||
tok = self.lex.peek() | ||
if tok != self.lex.tok_block_end: | ||
sys.stderr.write("end block expected, at %s\n" % self.lex.text) | ||
sys.stderr.write("%s: error: end block expected, at %s\n" % (sys.argv[0], self.lex.text)) | ||
return False | ||
self.lex.advance(skip_nl = True) | ||
return True | ||
|
@@ -278,7 +278,7 @@ def __parse_literal(self, str): | |
try: | ||
data = self.sym.getTerminal(str) | ||
except LookupError: | ||
sys.stderr.write("Error: unknown terminal %s\n" % self.lex.text) | ||
sys.stderr.write("%s: error: unknown terminal %s\n" % (sys.argv[0], self.lex.text)) | ||
return False | ||
self.lex.advance(skip_nl = False) | ||
if (self.if_stack[0] & self.mDoPrint) == self.mDoPrint: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
|
||
# pycrc -- parametrisable CRC calculation utility and C source code generator | ||
# | ||
# Copyright (c) 2006-2009 Thomas Pircher <[email protected]> | ||
# Copyright (c) 2006-2010 Thomas Pircher <[email protected]> | ||
# | ||
# Permission is hereby granted, free of charge, to any person obtaining a copy | ||
# of this software and associated documentation files (the "Software"), to deal | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,12 +2,12 @@ | |
<!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN" | ||
"http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd" [ | ||
<!ENTITY program_name "pycrc"> | ||
<!ENTITY program_version "0.7.1"> | ||
<!ENTITY program_version "0.7.4"> | ||
<!ENTITY date "2010-01-10"> | ||
<!ENTITY author_firstname "Thomas"> | ||
<!ENTITY author_surname "Pircher"> | ||
<!ENTITY author_email "[email protected]"> | ||
<!ENTITY author "&author_firstname; &author_surname;"> | ||
<!ENTITY date "2009-04-05"> | ||
<!ENTITY bit-by-bit "bit-by-bit"> | ||
<!ENTITY bit-by-bit-fast "bit-by-bit-fast"> | ||
<!ENTITY table-driven "table-driven"> | ||
|
@@ -205,8 +205,9 @@ | |
<replaceable>crc-8</replaceable>, | ||
<replaceable>dallas-1-wire</replaceable>, | ||
<replaceable>crc-15</replaceable>, | ||
<replaceable>crc-16-usb</replaceable>, | ||
<replaceable>crc-16</replaceable>, | ||
<replaceable>crc-16-usb</replaceable>, | ||
<replaceable>crc-16-modbus</replaceable>, | ||
<replaceable>ccitt</replaceable>, | ||
<replaceable>r-crc-16</replaceable>, | ||
<replaceable>kermit</replaceable>, | ||
|
Oops, something went wrong.