altos: ao_fec_prepare using wrong value for input len
authorKeith Packard <keithp@keithp.com>
Wed, 27 Mar 2024 04:38:48 +0000 (21:38 -0700)
committerKeith Packard <keithp@keithp.com>
Wed, 27 Mar 2024 04:38:48 +0000 (21:38 -0700)
The FEC code always sends a multiple of four bytes, padding by two
bytes for even inputs and one byte for odd. But the preparation step
was using the wrong value for the length, so the output was getting
mangled.

Signed-off-by: Keith Packard <keithp@keithp.com>
src/kernel/ao_fec_tx.c

index 8c0e7db4f7e51c4f6e7f92d092eacb3c6faa6713..209581b85efd28d2ca193c6e7c6e65686c6dbd25 100644 (file)
@@ -74,7 +74,7 @@ ao_fec_prepare(const uint8_t *in, uint8_t len, uint8_t *extra)
        extra[i++] = (uint8_t) crc;
 
        /* Append FEC -- 1 byte if odd, two bytes if even */
-       num_fec = 2 - (i & 1);
+       num_fec = 2 - (len & 1);
        while (num_fec--)
                extra[i++] = AO_FEC_TRELLIS_TERMINATOR;
        return i;