hex-in / libscrc

libscrc is a library for calculating CRC3 CRC4 CRC5 CRC6 CRC7 CRC8 CRC10 CRC11 CRC12 CRC15 CRC16 CRC24 CRC30 CRC31 CRC32 CRC64 CRC82
GNU General Public License v3.0
49 stars 13 forks source link

Argument refin and refout dose not work correctly for function hacker8() #8

Closed bnjmnp closed 3 years ago

bnjmnp commented 3 years ago

Thank you @hex-in for your effort to create and share this Python package, this is great work.

I need to calculate a crc8 variant that is not related to a standard. Therefore I tried to use the libscrc.hacker8() function. But it turned out that setting refin=True or refout=True dose not have any effect on the result.

If I do this:

import libscrc

crc8 = libscrc.hacker8(b'1234', poly=0x7, init=0, xorout=0, refin=False, refout=False)
print(hex(crc8))

crc8 = libscrc.hacker8(b'1234', poly=0x7, init=0, xorout=0, refin=True, refout=False)
print(hex(crc8))

crc8 = libscrc.hacker8(b'1234', poly=0x7, init=0, xorout=0, refin=False, refout=True)
print(hex(crc8))

crc8 is always 0xc2. But with refin=True it should be 0x70 and with refout=True it should be 0x43. I checked this with two online crc calculators. [1][2]

[1] http://www.sunshine2k.de/coding/javascript/crc/crc_js.html [2] http://zorc.breitbandkatze.de/crc.html

hex-in commented 3 years ago

Thank you @hex-in for your effort to create and share this Python package, this is great work.

I need to calculate a crc8 variant that is not related to a standard. Therefore I tried to use the libscrc.hacker8() function. But it turned out that setting refin=True or refout=True dose not have any effect on the result.

If I do this:

import libscrc

crc8 = libscrc.hacker8(b'1234', poly=0x7, init=0, xorout=0, refin=False, refout=False)
print(hex(crc8))

crc8 = libscrc.hacker8(b'1234', poly=0x7, init=0, xorout=0, refin=True, refout=False)
print(hex(crc8))

crc8 = libscrc.hacker8(b'1234', poly=0x7, init=0, xorout=0, refin=False, refout=True)
print(hex(crc8))

crc8 is always 0xc2. But with refin=True it should be 0x70 and with refout=True it should be 0x43. I checked this with two online crc calculators. [1][2]

[1] http://www.sunshine2k.de/coding/javascript/crc/crc_js.html [2] http://zorc.breitbandkatze.de/crc.html

Hi, I got your feedback,I will check to solve this problem as soon as possible. Thank you~

hex-in commented 3 years ago

Thank you @hex-in for your effort to create and share this Python package, this is great work.

I need to calculate a crc8 variant that is not related to a standard. Therefore I tried to use the libscrc.hacker8() function. But it turned out that setting refin=True or refout=True dose not have any effect on the result.

If I do this:

import libscrc

crc8 = libscrc.hacker8(b'1234', poly=0x7, init=0, xorout=0, refin=False, refout=False)
print(hex(crc8))

crc8 = libscrc.hacker8(b'1234', poly=0x7, init=0, xorout=0, refin=True, refout=False)
print(hex(crc8))

crc8 = libscrc.hacker8(b'1234', poly=0x7, init=0, xorout=0, refin=False, refout=True)
print(hex(crc8))

crc8 is always 0xc2. But with refin=True it should be 0x70 and with refout=True it should be 0x43. I checked this with two online crc calculators. [1][2]

[1] http://www.sunshine2k.de/coding/javascript/crc/crc_js.html [2] http://zorc.breitbandkatze.de/crc.html

Hi @bnjmnp I have fixed this issues. I will release it in v1.7

1 .Please tell me ur python and os version . I can release a version first and send *.whl package to you.

  1. You can build it by yourself (dev branches)

Finally, thank you very much for your issues.

Best regards.

hex-in commented 3 years ago

Please try again (Update latest version v1.7.1).

  1. pip3 uninstall libscrc
  2. pip3 install libscrc
hex-in commented 3 years ago

Please try again (Update latest version v1.7.1).

  1. pip3 uninstall libscrc
  2. pip3 install libscrc
bnjmnp commented 3 years ago

Very good. Now it is working fine. Thank you!