compatibility with bytes (#57)

This commit is contained in:
Xavier Olive
2019-12-31 11:15:25 +01:00
committed by Junzi Sun
parent 00fc1475ff
commit bddaf9aec6
+3 -1
View File
@@ -63,8 +63,10 @@ def crc(msg, encode=False):
# the CRC generator # the CRC generator
G = [int("11111111", 2), int("11111010", 2), int("00000100", 2), int("10000000", 2)] G = [int("11111111", 2), int("11111010", 2), int("00000100", 2), int("10000000", 2)]
if encode: if encode and isinstance(msg, str):
msg = msg[:-6] + "000000" msg = msg[:-6] + "000000"
elif encode:
msg = msg[:-6] + b"000000"
msgbin = hex2bin(msg) msgbin = hex2bin(msg)
msgbin_split = wrap(msgbin, 8) msgbin_split = wrap(msgbin, 8)