Skip to content

Commit 93af0c8

Browse files
authored
Merge pull request #265 from ivankravets/patch-1
Adapt code for Python 2/3
2 parents f1012ea + 1149b48 commit 93af0c8

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

tools/pynrfbintool/pynrfbintool.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def crc16(data):
3636
crc = 0xFFFF
3737
for c in data:
3838
crc = (((crc >> 8) & 0xFF) | (crc << 8)) & 0xFFFF
39-
crc = (crc ^ ord(c)) & 0xFFFF
39+
crc = (crc ^ (c if isinstance(c, int) else ord(c))) & 0xFFFF
4040
crc = (crc ^ ((crc & 0xFF) >> 4)) & 0xFFFF
4141
crc = (crc ^ ((crc << 8) << 4)) & 0xFFFF
4242
crc = (crc ^ (((crc & 0xFF) << 4) << 1)) & 0xFFFF
@@ -71,7 +71,7 @@ def create_app_signature(data):
7171
action='store_true',
7272
help='disable all console output unless an error occurs')
7373
args = parser.parse_args()
74-
74+
7575
# Make sure input filename exists.
7676
if not os.path.isfile(args.input):
7777
raise RuntimeError('Input file does not exist!')
@@ -90,13 +90,13 @@ def create_app_signature(data):
9090

9191
# Generate and write signature.
9292
if not args.quiet:
93-
print 'Writing signature to: {0}'.format(signature)
93+
print('Writing signature to: {0}'.format(signature))
9494
with open(signature, 'wb') as out_file:
9595
out_file.write(create_app_signature(data))
9696

9797
# Done!
9898
if not args.quiet:
99-
print 'Done!'
99+
print('Done!')
100100

101101

102102
# Unit Tests.

0 commit comments

Comments
 (0)