tehmaze/xmodem

broken API for calc_checksum

lestofante opened this issue · 1 comments

the example for checksum is simply:

csum = modem.calc_checksum('hello')

but this cause error:

return (sum(data) + checksum) % 256
TypeError: unsupported operand type(s) for +: 'int' and 'str'

quick fix:

return (sum(data) + checksum) % 256

should instead be

csum = sum(bytearray('hello', "utf-8")) % 256

or the API should be changed to

csum = modem.calc_checksum(bytearray('hello'))

The example in the API docs was for python2 syntax, I've changed 'hello' to b'hello' and the example works fine, thanks.