how to calculate ANSI CRC16 polynomial (0x8005) in python3?

跟風遠走 提交于 2019-12-13 16:22:06

问题


I tried to calculate ANSI CRC16 polynomial (0x8005) using this code

import crcmod
crc16 = crcmod.mkCrcFun(0x8005, 0xffff, True)

but I got this error message

ValueError: The degree of the polynomial must be 8, 16, 24, 32 or 64


回答1:


There is an implied 1 at the beginning of 0x8005

crcmod expects you to provide the 1 explicitly

import crcmod
crc16 = crcmod.mkCrcFun(0x18005, 0xffff, True)


来源:https://stackoverflow.com/questions/24851027/how-to-calculate-ansi-crc16-polynomial-0x8005-in-python3

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!