windytan / redsea

Command-line FM-RDS decoder with JSON output.
MIT License
390 stars 36 forks source link

Improve error correction if possible #15

Closed windytan closed 8 years ago

windytan commented 8 years ago

The error correction makes a lot of mistakes yet reports them as valid codewords (syndrome == 0). Two options:

  1. This should be fixed, or
  2. If it is a limitation of the error correction code itself, error correction should be disabled.

Here's an example of the error correction failing. The group is shown separated into blocks (4 hex characters) and checkwords (3 characters).

orig: 6A03/2C7 0421/14A F741/0C6 4557/1B8
err:  0800     0100     0000     0800
corr: 6203     0521              4D57

This leads to the PS string "YLMWUO" (should be "YLESUOMI"). It nevertheless gives syndrome 0 (no errors detected).

The syndrome calculation function (uint32_t calcSyndrome(uint32_t) in block_sync.cc) is a shift register implementation using obscure bit magic and should also be reviewed.

Here's what the RDS specs have to say about the error protection scheme:

The error-protecting code has the following error-checking capabilities [3, 4]:

a) Detects all single and double bit errors in a block. b) Detects any single error burst spanning 10 bits or less. c) Detects about 99.8% of bursts spanning 11 bits and about 99.9% of all longer bursts.

The code is also an optimal burst error correcting code [5] and is capable of correcting any single burst of span 5 bits or less.

The references point to:

[3] Peterson, W.W., and Brown, D.T.: Cyclic codes for error detection. Proceedings of the IRE, No. 49, January 1961, pp. 228-235. (pdf)

[4] Peterson, W.W., and Weldon, E.J.: Error-correcting codes. Published by MIT Press, Cambridge Mass., second edition, 1972.

[5] Kasami, T.: Optimum shortened cyclic codes for burst error correction. IEEE Transactions on Information Theory (IT9), No. 4, 1963, pp. 105-109. (doi)

windytan commented 8 years ago

Seems to be fixed now!