summaryrefslogtreecommitdiff
path: root/ARDOPC.c
diff options
context:
space:
mode:
Diffstat (limited to 'ARDOPC.c')
-rw-r--r--ARDOPC.c189
1 files changed, 0 insertions, 189 deletions
diff --git a/ARDOPC.c b/ARDOPC.c
index 3f93242..2652808 100644
--- a/ARDOPC.c
+++ b/ARDOPC.c
@@ -1024,195 +1024,6 @@ extern int kk; // Info Symbols
BOOL blnErrorsCorrected;
#define NEWRS
-
-BOOL xRSDecode(UCHAR * bytRcv, int Length, int CheckLen, BOOL * blnRSOK)
-{
-#ifdef NEWRS
-
- // Using a modified version of Henry Minsky's code
-
- //Copyright Henry Minsky (hqm@alum.mit.edu) 1991-2009
-
- // Rick's Implementation processes the byte array in reverse. and also
- // has the check bytes in the opposite order. I've modified the encoder
- // to allow for this, but so far haven't found a way to mske the decoder
- // work, so I have to reverse the data and checksum to decode G8BPQ Nov 2015
-
- // returns TRUE if was ok or correction succeeded, FALSE if correction impossible
-
- UCHAR intTemp[256]; // WOrk Area to pass to Decoder
- int i;
- UCHAR * ptr2 = intTemp;
- UCHAR * ptr1 = &bytRcv[Length - CheckLen -1]; // Last Byte of Data
-
- int DataLen = Length - CheckLen;
- int PadLength = 255 - Length; // Padding bytes needed for shortened RS codes
-
- *blnRSOK = FALSE;
-
- if (Length > 255 || Length < (1 + CheckLen)) //Too long or too short
- return FALSE;
-
- if (NPAR != CheckLen) // Changed RS Len, so recalc constants;
- {
- NPAR = CheckLen;
- MaxErrors = NPAR /2;
-
- initialize_ecc();
- }
-
-
- // We reverse the data while zero padding it to speed things up
-
- // We Need (Data Reversed) (Zero Padding) (Checkbytes Reversed)
-
- // Reverse Data
-
- for (i = 0; i < DataLen; i++)
- {
- *(ptr2++) = *(ptr1--);
- }
-
- // Clear padding
-
- memset(ptr2, 0, PadLength);
-
- ptr2+= PadLength;
-
- // Error Bits
-
- ptr1 = &bytRcv[Length - 1]; // End of check bytes
-
- for (i = 0; i < CheckLen; i++)
- {
- *(ptr2++) = *(ptr1--);
- }
-
- decode_data(intTemp, 255);
-
- // check if syndrome is all zeros
-
- if (check_syndrome() == 0)
- {
- // RS ok, so no need to correct
-
- *blnRSOK = TRUE;
- return TRUE; // No Need to Correct
- }
-
- if (correct_errors_erasures (intTemp, 255, 0, 0) == 0) // Dont support erasures at the momnet
-
- // Uncorrectable
-
- return FALSE;
-
- // Data has been corrected, so need to reverse again
-
- ptr1 = &intTemp[DataLen - 1];
- ptr2 = bytRcv; // Last Byte of Data
-
- for (i = 0; i < DataLen; i++)
- {
- *(ptr2++) = *(ptr1--);
- }
-
- // ?? Do we need to return the check bytes ??
-
- // Yes, so we can redo RS Check on supposedly connected frame
-
- ptr1 = &intTemp[254]; // End of Check Bytes
-
- for (i = 0; i < CheckLen; i++)
- {
- *(ptr2++) = *(ptr1--);
- }
-
- return TRUE;
-}
-
-#else
-
- // Old (Rick's) code
-
- // Sets blnRSOK if OK without correction
-
- // Returns TRUE if OK oe Corrected
- // False if Can't correct
-
-
- UCHAR intTemp[256]; // Work Area to pass to Decoder
- int i;
- int intStartIndex;
- UCHAR * ptr2 = intTemp;
- UCHAR * ptr1 = bytRcv;
- BOOL RSWasOK;
-
- int DataLen = Length - CheckLen;
- int PadLength = 255 - Length; // Padding bytes needed for shortened RS codes
-
- *blnRSOK = FALSE;
-
- if (Length > 255 || Length < (1 + CheckLen)) //Too long or too short
- return FALSE;
-
-
- if (NPAR != CheckLen) // Changed RS Len, so recalc constants;
- {
- NPAR = CheckLen;
- tt = sqrt(NPAR);
- kk = 255-CheckLen;
- generate_gf();
- gen_poly();
- }
-
- intStartIndex = 255 - Length; // set the start point for shortened RS codes
-
- // We always work on a 255 byte buffer, prepending zeros if neccessary
-
- // Clear padding
-
- memset(ptr2, 0, PadLength);
- ptr2 += PadLength;
-
- memcpy(ptr2, ptr1, Length);
-
- // convert to indexed form
-
- for(i = 0; i < 256; i++)
- {
-// intIsave = i;
-// intIndexSave = index_of[intTemp[i]];
- recd[i] = index_of[intTemp[i]];
- }
-
-// printtick("entering decode_rs");
-
- blnErrorsCorrected = FALSE;
-
- RSWasOK = decode_rs();
-
-// printtick("decode_rs Done");
-
- *blnRSOK = RSWasOK;
-
- if (RSWasOK)
- return TRUE;
-
- if(blnErrorsCorrected)
- {
- for (i = 0; i < DataLen; i++)
- {
- bytRcv[i] = recd[i + intStartIndex];
- }
- return TRUE;
- }
-
- return FALSE;
-}
-#endif
-
-
-
// Function to encode ConnectRequest frame