Closed apage43 closed 9 years ago
https://github.com/eerimoq/bincopy/blob/6093eacbfd8f53bbe7b4f349d0e06e1bd42e22e3/bincopy.py#L30
The line crc = (0x100 - crc) will give 0x100 instead of 0x00 for the two's complement of zero.
crc = (0x100 - crc)
Try crc = (~crc + 1) & 0xff instead.
crc = (~crc + 1) & 0xff
Thanks for the bug report. I corrected the code and added a unittest for ihex crc calculations.
https://github.com/eerimoq/bincopy/blob/6093eacbfd8f53bbe7b4f349d0e06e1bd42e22e3/bincopy.py#L30
The line
crc = (0x100 - crc)
will give 0x100 instead of 0x00 for the two's complement of zero.Try
crc = (~crc + 1) & 0xff
instead.