Closed
Description
Using bchlib=1.0.0 & python=3.12, I've found that consecutive calls of bch.decode
of the same bch
instance results most likely in wrong outputs. Steps to reproduce:
Consecutive bch.decode
calls:
>>> from bchlib import BCH
>>> from bitstring import Bits
>>> bch = BCH(t=16, prim_poly=8219)
>>> data = Bits(b"First").tobitarray()
>>> ecc = bch.encode(data)
>>> data2 = Bits(b"Second").tobitarray()
>>> ecc2 = bch.encode(data2)
>>> print(f"n-errors data: {bch.decode(data, ecc)}")
n-errors data: 0
>>> print(f"n-errors data2: {bch.decode(data2, ecc2)}")
n-errors data2: -1
I also added bch.correct
in between the decoding steps in case some cleanup would be done there. However, the result is the same.
Same as above, but without the first bch.decode
call:
>>> from bchlib import BCH
>>> from bitstring import Bits
>>> bch = BCH(t=16, prim_poly=8219)
>>> data = Bits(b"First").tobitarray()
>>> ecc = bch.encode(data)
>>> data2 = Bits(b"Second").tobitarray()
>>> ecc2 = bch.encode(data2)
>>> # print(f"n-errors data: {bch.decode(data, ecc)}")
>>> print(f"n-errors data2: {bch.decode(data2, ecc2)}")
n-errors data2: 0
Testing this using bchlib=0.14.0 worked fine as expected.