OpenGD77 DCS Feature

https://github.com/ajorg/OpenGD77/tree/dcs

Description

This implements DCS Tx and Rx. It correctly interprets Rx and Tx "tones" from the codeplug to distinguish from CTCSS and it uses the AT1846S chip to transmit and receive as is done with CTCSS.

The 83 standard codes are supported by the firmware but non-standard codes will also work if configured in the codeplug. See A Historical and Technical Overview of Tone Squelch Systems and DPL / DCS Information for why to stick to the 83 standard codes. In brief it's because the 83 codes can be uniquely identified from a number of positions in a stream of DCS data (which is streamed continuously during the entire call).

Implementation Notes

The AT1846S chip doesn't do Golay{23,12} encoding for you, so the ECC bits from the encoding are delivered as a lookup table. The table was computed using code from Using The Golay Error Detection And Correction Code by Hank Wallace:

#include <stdio.h>

/* This golay() function is (C) 2003 Hank Wallace from
   http://aqdi.com/articles/using-the-golay-error-detection-and-correction-code-3/
   Used here by permission.
 */
#define POLY  0xC75  /* or use the other polynomial, 0xAE3 */

unsigned long golay(unsigned long cw)
/* This function calculates [23,12] Golay codewords.
   The format of the returned longint is
   [checkbits(11),data(12)]. */
{
  int i;
  unsigned long c;
  cw&=0xfffl;
  c=cw; /* save original codeword */
  for (i=1; i<=12; i++)  /* examine each data bit */
    {
      if (cw & 1)        /* test data bit */
        cw^=POLY;        /* XOR polynomial */
      cw>>=1;            /* shift intermediate result */
    }
  return((cw<<12)|c);    /* assemble codeword */
}

/* This main() function is Copyright Andrew Jorgensen.
   SPDX-License-Identifier: MIT-0 */
int main()
{
    printf("\t");
    for (int i = 0; i <= 0777; i++)
    {
        unsigned int code = 04000 | i;
        printf("0x%03x", golay(code)>>12);
        if (i < 0777)
        {
            if ((i + 1) % 8 == 0)
                printf(",\n\t");
            else
                printf(", ");
        }
        else
            printf("\n");
    }
    return 0;
}

Because only the ECC bits are stored in the table it takes 1kB of space in the binary.

The ECC bits get a binary 100 appended to it and then the actual DCS code to make up the full 23 bits. This encoding allows the receiver to miss up to 3 bits while still decoding correctly.

The AT1846S supports using different tones for CTCSS Tx and Rx, but for DCS it only supports using the same code for both. But the codeplug can store a CTCSS tone for Rx and a DCS code for Tx and whatever other combinations you might come up with, so configuring Tx tones and codes for analog has been moved to PTT.

The codeplug stored the code in binary-coded-octal (not binary-coded-decimal) so conversion routines were added. The high two bits in the tone field are a flag that indicates that the code is DCS and a flag to indicate if the inverted code should be used. These bits will never be set in a valid CTCSS code because they don't go that high.

References to "tones" in the codeplug have been left untouched even though the tone might be a code or None. Some references to CTCSS have been changed to just CSS (Coded Squelch System, of which Carrier Tone is one).

The "None" value (0xFFFF) has been moved out of the TRX_CTCSSTones array and one non-standard tone was removed from that array also. Other tones will still work, probably including completely random frequency choices, if present in the codeplug.

Known Issues

  • Tx DCS doesn't apply when editing in Channel Details
  • DCS Inverted not yet supported (but possible)

TODO

  • Complete this document
  • Restore Daniel's skipping logic (possibly with a modifier key instead)
  • Inverted DCS (D023I etc.) support
  • User Guide updates
  • DCS_MASK instead of ~CODEPLUG_DCS_FLAGS_MASK and 0777
  • Move some code from trx.c to AT1846S.c?
  • Code cleanup / review

Test Plan

  • VFO
    • DCS Tx
      • Matches
      • Doesn't match
    • DCS Rx
      • Matches
      • Doesn't match
  • Channel
    • DCS Tx
    • DCS Rx
  • Channel Details
    • Temp
      • DCS Tx
      • CTCSS Tx
      • DCS Rx
      • CTCSS Rx
    • CTCSS Start Index
    • DCS Start Index