Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CRC16 Implementation Documentation #330

jcsoo opened this issue Apr 18, 2019 · 1 comment


Copy link

commented Apr 18, 2019

Comments in the protocol implementation suggest that a standard CRC16 calculation is being used with the polynomial 0x3D65 (typically used in CRC-16-DNP):

# Can be verified with
#print(hex(calc_crc8(0x12, [1, 2, 3, 4, 5, 0x10, 0x13, 0x37])))
#print(hex(calc_crc16(0xfeef, [1, 2, 3, 4, 5, 0x10, 0x13, 0x37])))

However, running the commented code produces 0x9a3a:

>>> hex(fibre.protocol.calc_crc16(0xfeef, [1, 2, 3, 4, 5, 0x10, 0x13, 0x37]))

which is a different result than what the referenced online calculator generates when using the the same polynomial and initial value:


It probably doesn't make sense to change the algorithm at this point, but if it really is different, it should be documented so that driver implementers know that they have to reproduce this specific algorithm rather than using an existing CRC library.

It would also be handy to have a few test cases to make it easier to confirm correct implementation.


This comment has been minimized.

Copy link

commented Jun 7, 2019

Existing CRC libraries should be capable of handling this fine. You need to untick the input and result reflection options in the CRC detailed parameters section and there is no final Xor'ing, so set that to 0x0 or leave blank. Doing so will yield 0x9A3A as the result.


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
2 participants
You can’t perform that action at this time.