Skip to content

fix: correct DSC decoder check-bit formula, add de-interleaving and 1… - #243

Open
blackwellj wants to merge 1 commit into
smittix:mainfrom
blackwellj:fix/dsc-decoder-checkbits-deinterleaving
Open

fix: correct DSC decoder check-bit formula, add de-interleaving and 1…#243
blackwellj wants to merge 1 commit into
smittix:mainfrom
blackwellj:fix/dsc-decoder-checkbits-deinterleaving

Conversation

@blackwellj

Copy link
Copy Markdown

…-bit error tolerance

Summary

The DSC decoder had several critical bugs that prevented correct decoding of DSC (Digital Selective Calling) messages per ITU-R M.493-16:

Bug fixes

  1. Wrong check-bit formula — used even parity (total 1s must be even) instead of the correct ITU-R M.493-16 algorithm: 3 check bits encode the count of B-elements (binary 0) among the 7 info bits as a 3-bit number (MSB first). This caused valid symbols to be rejected and invalid symbols to pass.

  2. Missing de-interleaving — DSC transmits every symbol twice (DX + RX copies ~5 positions apart). Without de-interleaving, duplicated symbols corrupted field boundaries. Added format-specifier anchor detection that takes every 2nd symbol to recover the original data.

  3. Format code mappings reversed — 102 was ALL_SHIPS (should be GEOGRAPHICAL_AREA), 112 was INDIVIDUAL (should be DISTRESS), 114 was INDIVIDUAL_ACK (should be GROUP), 116 was GROUP (should be ALL_SHIPS), 120 was DISTRESS (should be INDIVIDUAL), 123 was ALL_SHIPS_URGENCY_SAFETY (should be AUTOMATIC_SERVICE). Fixed all per ITU-R M.493-16.

  4. Missing format specifiers — added 100 (SELECTIVE_CALL), 113 (INDIVIDUAL_ACK), 115 (SHIP_POSITION), 118 (DISTRESS_RELAY), 121 (MEDICAL_TRANSPORT).

  5. Wrong position encoding — treated position symbols as 2-digit BCD values instead of single digits 0-9 per ITU-R M.493-11. Quadrant values were also wrong (0-3 instead of 10/11/00/01).

  6. Wrong distress nature codes — used value+100 (100-110) instead of the correct 0-31 range (lower 5 bits of symbol value).

  7. Wrong phasing symbol stripping — stripped symbols 120-126 unconditionally instead of using de-interleaving.

Improvements

  • 1-bit error tolerant symbol decoding: corrects single-bit errors during symbol-to-value conversion, dramatically improving decode rate on noisy signals.
  • De-interleaving with format-specifier anchor detection: handles the DX/RX duplication pattern in transmitted DSC messages.
  • Reusable symbol encoding/decoding utilities at module level (encode_symbol, bits_to_symbol, decode_mmsi, decode_position).
  • Updated all tests to match correct ITU-R M.493-16 specifications.

How to verify

…-bit error tolerance

## Summary

The DSC decoder had several critical bugs that prevented correct decoding
of DSC (Digital Selective Calling) messages per ITU-R M.493-16:

### Bug fixes

1. **Wrong check-bit formula** — used even parity (total 1s must be even)
   instead of the correct ITU-R M.493-16 algorithm: 3 check bits encode the
   count of B-elements (binary 0) among the 7 info bits as a 3-bit number
   (MSB first). This caused valid symbols to be rejected and invalid symbols
   to pass.

2. **Missing de-interleaving** — DSC transmits every symbol twice (DX + RX
   copies ~5 positions apart). Without de-interleaving, duplicated symbols
   corrupted field boundaries. Added format-specifier anchor detection that
   takes every 2nd symbol to recover the original data.

3. **Format code mappings reversed** — 102 was ALL_SHIPS (should be
   GEOGRAPHICAL_AREA), 112 was INDIVIDUAL (should be DISTRESS), 114 was
   INDIVIDUAL_ACK (should be GROUP), 116 was GROUP (should be ALL_SHIPS),
   120 was DISTRESS (should be INDIVIDUAL), 123 was ALL_SHIPS_URGENCY_SAFETY
   (should be AUTOMATIC_SERVICE). Fixed all per ITU-R M.493-16.

4. **Missing format specifiers** — added 100 (SELECTIVE_CALL), 113
   (INDIVIDUAL_ACK), 115 (SHIP_POSITION), 118 (DISTRESS_RELAY), 121
   (MEDICAL_TRANSPORT).

5. **Wrong position encoding** — treated position symbols as 2-digit BCD
   values instead of single digits 0-9 per ITU-R M.493-11. Quadrant values
   were also wrong (0-3 instead of 10/11/00/01).

6. **Wrong distress nature codes** — used value+100 (100-110) instead of the
   correct 0-31 range (lower 5 bits of symbol value).

7. **Wrong phasing symbol stripping** — stripped symbols 120-126
   unconditionally instead of using de-interleaving.

### Improvements

- 1-bit error tolerant symbol decoding: corrects single-bit errors during
  symbol-to-value conversion, dramatically improving decode rate on noisy
  signals.
- De-interleaving with format-specifier anchor detection: handles the DX/RX
  duplication pattern in transmitted DSC messages.
- Reusable symbol encoding/decoding utilities at module level
  (encode_symbol, bits_to_symbol, decode_mmsi, decode_position).
- Updated all tests to match correct ITU-R M.493-16 specifications.

### How to verify
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant